AlexeyTaranov / SerializeReferenceDropdown

(Unity) Editor dropdown for SerializeReference Attribute with Copy/Paste
MIT License
89 stars 7 forks source link

Private field in base class #1

Closed AlexeyTaranov closed 2 years ago

AlexeyTaranov commented 2 years ago

Istance of class with private field in base (with SRD and serialize reference). Solve error: replace private with protected =)

NullReferenceException: Object reference not set to an instance of an object
SRD.Editor.SerializedPropertyInfo.GetIndexAssignedTypeOfProperty (UnityEditor.SerializedProperty property) (at Library/PackageCache/com.alexeytaranov.srd@6f7a8f2aa4/Editor/SerializedPropertyInfo.cs:64)
SRD.Editor.SRDDrawer.DrawSRDTypeDropdown (UnityEngine.Rect rect, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at Library/PackageCache/com.alexeytaranov.srd@6f7a8f2aa4/Editor/SRDDrawer.cs:54)
SRD.Editor.SRDDrawer.OnGUI (UnityEngine.Rect rect, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) ....

Ecample: create component with type Parent.

public interface IShape
{
}

[Serializable]
public class Circle : IShape
{
    [SerializeField]
    private float _radius;
}

public class BaseClass : MonoBehaviour
{
    [SRD]
    [SerializeReference]
    private IShape _singleShape;
}

public class Parent : BaseClass 
{
}