In this lesson we will create some layout for our custom inspector to have a better control on the layout of our inspector window
We will start with EdiorGUILayout Class
In our code write
After clicking save when we go back to unity we will see all
our GUI elements in a single horizontal line.
This is not what we want. So to fix this we add our GUI elements inside BeginVertical and EndVertical Layout.
Now our Code will look like this
Clicking on save we will notice our layout gets change back to vertical and all the GUI elements get stacked on top of each other
One more feature that these layout allow us is adjusting the space between GUI elements
In our code we will add
In the horizontal layout we add GUILayout.Space(10) to add 10px space on both ends of the horizontal layout
Now we can go further and add space between our GUI elements by adding GUILayout.Space(10) between our GUI elements
In our code we will add
Since we are in a Vertical Container so this will affect in a vertical fashion.Click save and check in the inspector window
Now you will see a space of 10 px between the GUI elements.
This concludes our current lesson. Now in the next lesson we will learn about GUIContent which allow us to create our custom labels for all our GUI elements.
We will start with EdiorGUILayout Class
In our code write
After clicking save when we go back to unity we will see all
our GUI elements in a single horizontal line.
This is not what we want. So to fix this we add our GUI elements inside BeginVertical and EndVertical Layout.
Now our Code will look like this
Clicking on save we will notice our layout gets change back to vertical and all the GUI elements get stacked on top of each other
One more feature that these layout allow us is adjusting the space between GUI elements
In our code we will add
In the horizontal layout we add GUILayout.Space(10) to add 10px space on both ends of the horizontal layout
Now we can go further and add space between our GUI elements by adding GUILayout.Space(10) between our GUI elements
In our code we will add
Now you will see a space of 10 px between the GUI elements.
This concludes our current lesson. Now in the next lesson we will learn about GUIContent which allow us to create our custom labels for all our GUI elements.
No comments:
Post a Comment