In this lesson we will add some GUI content to our custom inspector which will help us to add either
So lets start by adding a sample icon to our GUI elements.
I'll be using this image as a sample
You can use any image that you would like to based on your needs.
We need to import this image inside Unity.
Create a folder named Resources inside the Editor Folder and then import the image inside this folder like this
Now select the image and set the texture property to GUI as we will be using this image for our GUI elements.
Now in our Code add the following lines
Click save and now go back to unity and check the inspector window to see the changes
This concludes our lesson on GUIContent.
- Image Icon
- Text
- Tooltip
So lets start by adding a sample icon to our GUI elements.
I'll be using this image as a sample
You can use any image that you would like to based on your needs.
We need to import this image inside Unity.
Create a folder named Resources inside the Editor Folder and then import the image inside this folder like this
Now select the image and set the texture property to GUI as we will be using this image for our GUI elements.
Now in our Code add the following lines
- We create a Texture2D object to hold our GUI texture that we just imported.
- We create a GUIContent object that will help us to add text,icon and tooltip field to our GUI elements.
- In OnInspectorGUI() method we will load our texture from our resources folder.
- Next we add the image,text and tooltip to our GUIContent object we created and assign them to the GUI elements.
Click save and now go back to unity and check the inspector window to see the changes
Our final output looks like this
This concludes our lesson on GUIContent.
In the next lesson we will create some GUI Buttons to our custom inspector.
Comments
Post a Comment