Game Development Reference
In-Depth Information
EditorUtility.FocusProjectWindow();
Selection.activeObject = positionManager;
}
}
Note
Any script that uses the UnityEditor namespace has to be placed in a special Editor
folder. This ensures that it is only packaged with the editor solution and not used in the
deployed game. Game projects are not deployed with the editor.
There is a lot to explain, but it is all commented very well in short, as follows:
• We define a menu option from where we will call our creation code
• We set up a new object that we want to serialize and create the file where it is to
be stored
• We change the view of the editor to focus the inspector on the new object
Note
If you create custom classes to be used in serialization, you must tag those classes with the
[System.Serializable] attribute. Otherwise, Unity will not know that they are for
serialization. We will cover more on this later in the implemented example.
If you return to Unity now and right-click on the Asset folder (or click on the Create
menu option in the Project view), you will see the new menu option you just created, as
shown in the following screenshot:
Search WWH ::




Custom Search