Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Jul 17, 2018 at 04:38 PM by YoloJero for the following reason:

Problem is not reproducible or outdated

avatar image
0
Question by YoloJero · May 02, 2018 at 07:56 AM · editor-scriptingnullreferenceexceptioncustom editorserializedproperty

ReorderableList Custom Editor Count -> NullReferenceExeception

Hi I have trouble getting ReorderableList to run in a custom Editor.

I followed this Tutorial: http://va.lent.in/unity-make-your-lists-functional-with-reorderablelist/

But I get an exception:

NullReferenceException: Object reference not set to an instance of an object UnityEditorInternal.ReorderableList.get_count () (at C:/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:371)
UnityEditorInternal.ReorderableList.GetListElementHeight () (at C:/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:424)
UnityEditorInternal.ReorderableList.DoLayoutList () (at C:/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:383)


Here is the relevant code I got so far:

 using UnityEngine;
 using UnityEditor;
 using UnityEditorInternal;
 
 public class MyClass : Monobehaviour
 {
     [SerializeField] 
     private List<object> _entries = new List<object>();
 }
 
 public class MyClassEditor : Editor
 {
     private SerializedProperty _entries;
     private ReorderableList _entryList;
 
     private void OnEnable()
     {
         _entries = serializedObject.FindProperty("_entries");
         _entryList = new ReorderableList(serializedObject, _entries, false, false, false, false);
     }
 
     public override void OnInspectorGUI()
     {
         serializedObject.Update();
 
         _entryList.DoLayoutList();
 
         serializedObject.ApplyModifiedProperties();
     }
 }


The exception occures for the line _entryList.DoLayoutList();.


So I made a brake point in VS and saw that it is always thrown for the count property: exception in VS for count property of _entryList


What am I doing wrong?

capture.png (20.4 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by YoloJero · May 02, 2018 at 08:01 AM

Hi never mind _entries was null in the MyClassEditor since object is not serializeable in Unity. I changed it now to use a custom class.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Follow this Question

Answers Answers and Comments

93 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I use a GUIStyle in a Custom Editor which is set within that Custom Editor? 1 Answer

Why is my propertydrawer being automatically disabled? 1 Answer

Serializedproperty assignment 2 Answers

Should EditorGUILayout.PropertyField work with serializable classes? 1 Answer

How to create a new SerializedProperty? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges