-
Book Overview & Buying
-
Table Of Contents
Extending Unity with Editor Scripting
By :
Most of the interaction with Level Creator is going to be performed through the mouse. In this section, will learn how to capture events in the Scene View.
The Event class, part of the UnityEngine namespace, allows you to handle user inputs such as key presses or mouse actions.
Let's update the method EventHandler inside the LevelInspector class:
private void EventHandler() {
HandleUtility.AddDefaultControl(
GUIUtility.GetControlID(FocusType.Passive));
Vector3 mousePosition = Event.current.mousePosition;
Debug.LogFormat("MousePos: {0}", mousePosition);
}The variable Event.current has the information about the current event that's being processed in the Scene View.
From current, we are accessing the variable mousePosition to determine in which X and Y positions, relative to the Scene View coordinate system, the cursor of the mouse is found.
Save the changes and wait for Unity to compile. Now create a new level scene, select...
Change the font size
Change margin width
Change background colour