Hey everybody, I've been getting hounded by a nullreference error while using array.Length in a C# editor script
This is the editor script (With unnecessary script lines removed)
And this is the actual script affected:
The above posted is what I've narrowed down as the problem, I've been working at it for a while and have had no prevail! To the best of my knowledge, this should be working but it gives this error (ignore line reference):
NullReferenceException: Object reference not set to an instance of an object SentryTurretAIEditor.OnInspectorGUI () (at Assets/Editor/SentryTurretAIEditor.cs:14) UnityEditor.InspectorWindow.DrawEditors (Boolean isRepaintEvent, UnityEditor.Editor editors, Boolean eyeDropperDirty) UnityEditor.InspectorWindow.OnGUI () System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object parameters, System.Globalization.CultureInfo culture)
Any help would be absolutely amazing!
asked Aug 26 '11 at 10:26 AM
It seems that your
Arrays need to be created, just like any other object. The problem with an array is that you have to specify the length at creation time.
answered Aug 26 '11 at 10:37 AM