-
Notifications
You must be signed in to change notification settings - Fork 7
Coding_Tips
This page is dedicated to a series of tips and tricks for more experienced developers using LUTE.
Most of the code that forms LUTE is known as 'Editor Code' which assumes that the we are building scripts and classes to be used alongside the built in GUI of Unity. For example, you may find that some Orders look different in the Inspector View to how they have been defined in their class (such as custom drop downs and toggle states). This is because we are using 'Editor Code' to define how the serialised properties will be displayed in the Unity GUI.
If we take a look at the order Choice we can see that the properties are not displayed in the Inspector in the same format as they have been defined in the class itself. This is because we have defined the editor side of the class in a separate class: ChoiceEditor.cs. This class derives from OrderEditor which itselfs derives from the Editor class which is a predefined class supplied by the UnityEditor namespace.
The Editor class provides methods that can overrided and allow the inspector to be defined in a custom fashion (OnInspectorGUI).
Typically, to write your own editor scripts for Orders this convention is suitable:
[CustomEditor(typeof(Choice))] public class ChoiceEditor : OrderEditor
The above is intended to be implemented to customise inspector properties for Orders but this process can be applied to other aspects. For example, both Nodes and Groups editor classes have been defined in other classes to create more user friendly GUI.
We provide multiple methods for creating dropdowns and grabbing properties from other classes to make creating editor code a bit easier for you; the code itself is buried quite deeply in other classes and does require some knowledge of the system - editing such methods and implementations is done at the risk of the developer.