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 /
  • Help Room /
avatar image
2
Question by retraffic · Jan 18, 2017 at 12:01 PM · inspectornullreferenceexceptioneventsystemevents

UnityEvent NullreferenceException in inspector

I'm getting an error whenever I try to add an Event to a UnityEvent field in the inspector (clicking on the plus symbol in the corner). Whenever I hit the I'm running Unity 5.5.0f3 and have tried restarting Unity several times. It's not happening to all UnityEvents I'm using, just these ones, that are in a serializable class rather deep in the object hierarchy. Could the problem be that the definition is too deep in the object hierarchy? I have a Monobehaviour that has a serializable-class variable, that has a list of another serializable-class variable that contains a list of type customEvent.

Selfdefined Events UnityEvent field in inspector gif version

The code:

 [System.Serializable]
 public class customEvent
 {
 
 
 
     public List<GameEvent> events;
     public UnityEvent selfdefinedEvents;
  
 
     public void Invoke(room_controller rooms)
     {
         foreach (GameEvent ge in events)
         {
 
             ge.Invoke(rooms);
 
         }
 
         selfdefinedEvents.Invoke();
 
     }
 }
 




The error: NullReferenceException: Object reference not set to an instance of an object UnityEditorInternal.UnityEventDrawer.AddEventListener (UnityEditorInternal.ReorderableList list) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/UnityEventDrawer.cs:365) UnityEditorInternal.ReorderableList+Defaults.DrawFooter (Rect rect, UnityEditorInternal.ReorderableList list) (at /Users/builduser/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:105) UnityEditorInternal.ReorderableList.DoListFooter (Rect footerRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:627) UnityEditorInternal.ReorderableList.DoList (Rect rect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:400) UnityEditorInternal.UnityEventDrawer.OnGUI (Rect position) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/UnityEventDrawer.cs:157) UnityEditorInternal.UnityEventDrawer.OnGUI (Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/UnityEventDrawer.cs:123) UnityEditor.PropertyDrawer.OnGUISafe (Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at /Users/builduser/buildslave/unity/build/Editor/Mono/ScriptAttributeGUI/PropertyDrawer.cs:23) UnityEditor.PropertyHandler.OnGUI (Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, Boolean includeChildren) (at /Users/builduser/buildslave/unity/build/Editor/Mono/ScriptAttributeGUI/PropertyHandler.cs:134) UnityEditor.EditorGUI.PropertyFieldInternal (Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, Boolean includeChildren) (at /Users/builduser/buildslave/unity/build/Editor/Mono/EditorGUI.cs:5158) UnityEditor.EditorGUI.PropertyField (Rect position, UnityEditor.SerializedProperty property, Boolean includeChildren) (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/editor/EditorGUIBindings.gen.cs:1041) UnityEditor.EditorGUI.PropertyField (Rect position, UnityEditor.SerializedProperty property) (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/editor/EditorGUIBindings.gen.cs:1036) UnityEditor.Editor.OptimizedInspectorGUIImplementation (Rect contentRect) (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/editor/EditorBindings.gen.cs:233) UnityEditor.GenericInspector.OnOptimizedInspectorGUI (Rect contentRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/GenericInspector.cs:33) UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1216) UnityEditor.InspectorWindow.DrawEditors (UnityEditor.Editor[] editors) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1031) UnityEditor.InspectorWindow.OnGUI () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:356) System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

unityerror.jpg (45.7 kB)
Comment
Add comment · Show 3
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
avatar image PedroCoriAG · Jul 18, 2017 at 06:55 PM 0
Share

Did you ever manage to fix this? I'm having the exact same problem right now.

avatar image KylBot · Dec 27, 2017 at 11:36 PM 0
Share

I'm also now experiencing this issue. I've been using custom UnityEvents for a long time now and this is the first time I've run into this error.

For me, it's happening from referencing a struct with 2 UnityEvents [Defined in another script] from a fairly deeply nested set of structs (So a very similar setup to what you've got). It's a complicated bit of code for a compiler so I understand why it may be freaking out but exactly one layer up in the set of arrays, it works perfectly fine.

Seems to be an issue with the Editor drawing nested arrays of objects with Events at the bottom for some reason.

Hopefully someone comes along and helps with this extremely specific (and thus easily overlooked) issue.

[Unity 2017.3.0f3]

avatar image shadowjet323 · Apr 19, 2019 at 10:46 PM 0
Share

I know this is old but I'm having the same problem : (

Edit: nvm

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

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

UnityEvent Generic (Inspector Serialization) 0 Answers

Event NullReferenceException 1 Answer

How do I keep methods being called until the current one has finished running 0 Answers

Count and find NON-PERSISTENT UnityEvent listeners: How? 1 Answer

ScrollBar and scrollrect seem not working on mobile 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