0
\$\begingroup\$

I am trying to draw the inspector gui from components from a prefab to my own editor window but then this error gets produced and I have no idea how to solve it.

NullReferenceException: (null) UnityEditor.SerializedObject..ctor (UnityEngine.Object[] objs, UnityEngine.Object context) (at C:/buildslave/unity/build/Editor/Mono/SerializedObject.cs:26) UnityEditor.Editor.GetSerializedObjectInternal () (at C:/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:516) UnityEditor.Editor.get_serializedObject () (at C:/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:433) UnityEditor.RectTransformEditor.OnEnable () (at C:/buildslave/unity/build/Editor/Mono/Inspector/RectTransformEditor.cs:100)

         [SerializeField]
         protected List<Component> components;

#if UNITY_EDITOR

        private UnityEditor.Editor[] contentEditors;

#endif

         private void SetupEditors()
         {
#if UNITY_EDITOR
            contentEditors = new UnityEditor.Editor[components.Count];
            for (int i = 0; i < components.Count; i++)
            {
                contentEditors[i] = UnityEditor.Editor.CreateEditor(components[i]);
            }
#endif
         }
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.