Let's Create - Custom Inspector in Unity

Download this episode

Download Video


Full source project:  https://github.com/jasonrwalters/Unity_CustomInspector

Display variables created in scripts to be displayed in a GameObject's inspector.
- Useful for adjusting game parameters during play tests in the Unity Editor.
- Useful for debugging values when you do not need to draw messages to the screen.

Public Variables
Public variables will be displayed in the inspector. Note, `public static` variables will NOT be displayed in the inspector.

public float var1;
public int var2;
public bool var3;

Private Variables
In order to see private variables in the inspector, you must place `[SerializeField]` ahead of each item.
private float var1; 
private int var2; 
private bool var3;

public string text = "This is a string";

Use `[Space(height)]` between each item that requires a space. Height is in pixels.
public float var1; 
public float var2;
public float var3;

Place `[Range(min, max)]` ahead of variables that need a slider in the inspector. Requires a minimum and maximum value.
[Range(1f, 10f)] 
public float var1; 

Drop Downs
public enum Selector 
One = 0, 
Two = 1, 
Three = 2, 
Four = 3 
public Selector select = Selector.One;

public Color rgba;
public Gradient gradient;



Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.