Pages

Tuesday, 14 July 2015

Create Unity Custom Editor - Basics (Part 8) -More GUI elements

In this section we'll create some more interactive gui elements inside our custom editor script
We'll use GUILayout.Button(); to create a button
Notice: This has a bunch of override's that you can look into based on your needs.
For additional reference click here

Now inside our editor script we'll add
GUILayout.Button("Click Me!", GUILayout.Height(40)); 
to create a button with a height of 40 pixels.
So our result will look something like this. Right now the button just sits there and does nothing when we click on it. Let's work on that functionality.

Create Unity Custom Editor - Basics (Part 7) - Inspector Layout

In this lesson we will work on organizing our GUI elements inside the inspector in a more visually appealing manner .

To start with lets wrap our code inside a container by using
EditorGUILayout.BeginHorizontal();
and every time you start with this you have to end the layout by using

EditorGUILayout.EndHorizontal();
Important: Make sure you keep a track of these

Here's the Code
You will notice that all of the GUI elements will align horizontally and some may even go out of the inspector window. However, this is not what we want.

We want our inspector window to look more visually attractive and easy to use. So in order to do that we will nest our container with a BeginVertical and EndVertical layout.
Here's how our code will look like
Notice i have added GUILayout.Space(10) to give some spacing from the margins as well as between the GUI elements.
This concludes the current lesson. In the next section we'll create some more interactive gui elements like buttons,sliders etc.

Tuesday, 6 January 2015

Create Unity Custom Editor - Basics (Part 6)

In this lesson we will add some GUI content to our custom inspector which will help us to add either

  • Image Icon
  • Text
  • Tooltip
to our GUI elements.

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

Monday, 5 January 2015

Create Unity Custom Editor - Basics (Part 5)

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

Sunday, 4 January 2015

Create Unity Custom Editor - Basics (Part 4)

In the last lesson we linked our custom editor script with our test script.

In this lesson we are going to create some custom GUI elements.

So lets get started with that

1) Jump to the Editor Script and comment out the DrawDefaultInspector() so that we can start adding our own custom elements

Lets get started with introducing some GUI elements that we can create inside the inspector
The most basic one is a label
2) We will be using EditorGUILayout class to show our label inside the inspector.
This class has got tons of other types of functions which you can use

Goto this link and checkout the other functions available inside the EditorGUILayout class.

I would recommend to spend sometime on

Saturday, 3 January 2015

Create Unity Custom Editor - Basics (Part 3)

In the previous lesson we covered the core structure of our project and now we are ready to create our own custom inspector.

In this lesson we will link our custom inspector script with our monobehaviour script.

So lets get started

1) Create a new GameObject inside the hierarchy and attach the TestScript that we created in the previous lesson.
















2) Now open the TestScript and

Friday, 2 January 2015

Create Unity Custom Editor - Basics (Part 2)

In the previous part we basically created a fundamental structure setup for us to create an Inspector Editor.

Now we will start creating some scripts so lets dive in.


1) Create a new  C# script (TestScript) inside the Scripts folder we created in part 1( You can name anything related to your project but to keep things simple for this lesson i am taking this name)



 
















2) Create a new C# script (TestScriptEditor) inside the Editor folder we created in part 1( We named it accordingly so that we know that it is an editor script which will be used as a custom inspector)















3) Open the Scripts inside Monodevelop or any other Editor that you use for