Game Development Reference
In-Depth Information
To show this, let's add an additional method to the previous script (a public one this
time) as follows:
public void RunMeFromTheInspector()
{
Debug.Log("Look, I was configured in the inspector");
}
Then in the inspector, do the following:
1.
Select the SimpleEventObject .
2.
Click on the + symbol of the UnityEvent property drawer to register a
new Event .
3.
Leave the Runtime Only option alone, since we don't need it running in
the editor.
The option Editor And Runtime is effectively the same as using the
[ExecuteInEditMode] code attribute you can use in code. Just runs it
continually while the editor is open as well as when the game is running.
Refer to http://docs.unity3d.com/ScriptReference/
ExecuteInEditMode.html for more information.
4.
Select the SimpleEventObject using the object selector in the field below
the Runtime Only option (or drag the GameObject from the scene on to the
field). This selects the object the Event is to fire against.
5.
Finally, use the drop-down box to the right of the Runtime Only option to
select the action to fire on the selected GameObject. In this case, select the
SimpleEvent | RunMeFromTheInspector() option to run our new delegate
function we created earlier.
This should result in the following view in the Inspector with the
SimpleEventObject selected in the hierarchy:
 
Search WWH ::




Custom Search