- Home /
Custom inspector: function for assets?
I am making a custom inspector, how do I make a field for say a sprite?
Answer by MikeNewall · May 13, 2014 at 11:27 PM
An object field:
http://docs.unity3d.com/Documentation/ScriptReference/EditorGUILayout.ObjectField.html
Answer by deathbane · May 15, 2014 at 03:05 AM
I am using this for a sprite and whenever I try to assign it it gives me this error.
NullReferenceException: Object reference not set to an instance of an object UnityEditor.EditorGUI.ValidateObjectFieldAssignment (UnityEngine.Object[] references, System.Type objType, UnityEditor.SerializedProperty property) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/EditorGUI.cs:2454) UnityEditor.EditorGUI.DoObjectField (Rect position, Rect dropRect, Int32 id, UnityEngine.Object obj, System.Type objType, UnityEditor.SerializedProperty property, UnityEditor.ObjectFieldValidator validator, Boolean allowSceneObjects, UnityEngine.GUIStyle style) (at C:/BuildAgent/work/d3d49558e4d408f4/Editor/Mono/GUI/ObjectField.cs:44) UnityEditor.EditorGUI.DoObjectField (Rect position, Rect dropRect, Int32 id, UnityEngine.Object obj, System.Type objType, UnityEditor.SerializedProperty property, UnityEditor.ObjectFieldValidator validator, Boolean allowSceneObjects) (at C:/BuildAgent/work/d3d49558e4d408f4/Editor/Mono/GUI/ObjectField.cs:12) UnityEditor.EditorGUI.ObjectField (Rect position, UnityEngine.Object obj, System.Type objType, Boolean allowSceneObjects) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/EditorGUI.cs:2380) CourseBlockEdit.OnInspectorGUI () (at Assets/Editor/CourseBlockEdit.cs:20) UnityEditor.InspectorWindow.DrawEditors (Boolean isRepaintEvent, UnityEditor.Editor[] editors, Boolean eyeDropperDirty) (at C:/BuildAgent/work/d3d49558e4d408f4/Editor/Mono/Inspector/InspectorWindow.cs:850) UnityEditor.DockArea:OnGUI()
Edit: if it matters I am not using GUILayout.objectfeild() I am using GUI.objectFeild()
Answer by sadrimohsen05 · Dec 23, 2021 at 11:15 AM
Hello I want to create a series of 75 x 75 squares in the editor environment by giving the length and width value. How can this be? Thanks