Skip to content

非パブリックなSerializeFieldを持つクラスを継承した際の不具合を修正 #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

takuma-komatsu
Copy link
Contributor

下記のようなコードで発生する不具合に暫定対処しました。

using System;
using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu]
public class ErrorSample : ErrorSampleBase
{
}

public abstract class ErrorSampleBase : ScriptableObject
{
    [Serializable]
    public class /* or struct */ Nested
    {
        public string Value;
    }

    // Valueがインスペクタに表示されない
    [SerializeField] private Nested _nested;

    // 「+」ボタンを押すと例外(※下記)が発生する
    [SerializeField] private List<Nested> _nestedList;

    // intやstringだと問題なく表示される
    [SerializeField] private string _stringValue;
    [SerializeField] private List<string> _stringList;
}

発生する例外

NullReferenceException: Object reference not set to an instance of an object
Alchemy.Editor.SerializedPropertyExtensions.GetElementAtOrDefault (System.Object arrayOrListObj, System.Int32 index) (at Assets/Alchemy/Editor/Internal/SerializedPropertyExtensions.cs:204)
Alchemy.Editor.SerializedPropertyExtensions.GetNestedObject[T] (System.String path, System.Object obj, System.Boolean includeAllBases) (at Assets/Alchemy/Editor/Internal/SerializedPropertyExtensions.cs:168)
Alchemy.Editor.SerializedPropertyExtensions.GetValue[T] (UnityEditor.SerializedProperty property) (at Assets/Alchemy/Editor/Internal/SerializedPropertyExtensions.cs:55)
Alchemy.Editor.Elements.AlchemyPropertyField..ctor (UnityEditor.SerializedProperty property, System.Type type, System.Boolean isArrayElement) (at Assets/Alchemy/Editor/Elements/AlchemyPropertyField.cs:62)
Alchemy.Editor.Elements.PropertyListView+<>c__DisplayClass0_1.<.ctor>b__0 (UnityEngine.UIElements.VisualElement element, System.Int32 index) (at Assets/Alchemy/Editor/Elements/PropertyListView.cs:27)

@nuskey8 nuskey8 merged commit 071db9f into annulusgames:main Jun 15, 2025
@nuskey8
Copy link
Member

nuskey8 commented Jun 15, 2025

PRをマージしました。ありがとうございます!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants