- Home /
Inspector scripting, adding lists, checkboxes and buttons [With Image]
Hey guys, I have a relatively easy(I hope) question about inspector scripting. I am making a script that will instance a variety of models and move them to the left as in a side scrolling space shooter. I have several levels(stages) that I need instanced.
So my question is how can I create elements visible in the right image. I'd like to have a list that will load different parameters below it depending on the stage selected. In addition to buttons and checkboxes. Also, if I need a different script file, how may I connect it to my main script?
Thanks a lot for any leads!
Is your question about how to make a specific look for a specific item, like the header in the list on the right? Or do you wonder how to override the default inspector so you can draw whatever you want in it?
I'd like to be able to override it and enable the user to add items to a list, which the script I make will then read from and change variables accordingly.
Creating your own custom Inspector look can be complex, especially if you really want to make it highly configured. Take a look at the ICE AI character controller Inspector for a fine example of how amazing and detailed it can be.
But I think you're looking for this:
First, you'll need the class that has the data you want to display, then you'll need another class that's sub-classes Editor, which will access that first data class (through target), and perform the actual Inspector display.
Here's the Unity tutorial on custom Inspectors: https://unity3d.com/learn/tutorials/topics/interface-essentials/building-custom-inspector
Here's the scripting manual link for EditorGUILayout: https://docs.unity3d.com/ScriptReference/EditorGUILayout.html
I'm only just beginning to do this myself, so it's still a slow progress as I have to look up everything and learn as I go :)