- Home /
Unity Editor script arrows to display a variable
So what I am trying to achieve is this:
Notice how in GUI skins, there are different areas in case your skin is for buttons, sliders, labels etc...
Notice how there are arrows that reveal other stuff inside. How can i do this in a script i add to an object and when i click an arrow it reveals other variables?
Thanks
Answer by SterlingSoftworks · Feb 03, 2016 at 06:59 AM
In order to do stuff like this you need to start getting into creating custom classes for your scripts.
SOOOO above (or below) your script that you want these fancy stuffs you need to create your custom class
//100% need using System
using System;
[System.Serializable]
public class customClass{
public int intVariableOne;
public int intVariableTwo;
//You get the idea
}
Then all you have to do is a customClass variable, like you would an int or a bool.
public customClass yayDropDown;
And now in your inspector you'll have a drop down-able variable group called "yayDropDown" (or whatever) that has all the variables you made in the customClass.
Then, in order to access those variables you reference the variable you made
yayDropDown.intVariableOne = 12;
Hope this helps :)
Not really what I needed. I've known how to do that for a long time now. All it does is when I make an object of my class, display it in the editor and when you click the arrows, it displays all the variables of the object.
What I'm looking for is when you make an object, there is 1 arrow, then when you open it, there are many other arrows, which reveal many variables inside of them. Just like you can see in the gui skin
Answer by SquareMike · May 03, 2019 at 08:48 PM
I know this is a very old question but I'm going to post this for anyone else that has the same question. You can achieve folder-like structures by using EditorGUILayout.Foldout in your script file.
Your answer
Follow this Question
Related Questions
Custom Timeline Playable - GUI Override 0 Answers
How to add a reorderable list on CUSTOM EDITOR WINDOW? 0 Answers
Custom Editor for interfaces 2 Answers
EditorGUILayout.TextField text get's deleted instantly. 2 Answers
Importing .png via script 1 Answer