This looks very similar (although the “Script” field is now not present, because the editor script does not add any Inspector code to show it).
This is how the Inspector for the LookAtPoint component looks with the new editor: Editor defines the target property that you can use to access the GameObject you are inspecting. You can put any GUI code in here and it works in the same way as OnGUI does, but runs inside the Inspector. Unity executes the code in OnInspectorGUI it displays the editor in the Inspector. The CanEditMultipleObjects attribute tells Unity that you can select multiple objects with this editor and change them all at the same time. The CustomEditor attribute informs Unity which component it should act as an editor for. SerializedObject.ApplyModifiedProperties() LookAtPoint = serializedObject.FindProperty("lookAtPoint") ĮditorGUILayout.PropertyField(lookAtPoint) Create a new C# script and name it “LookAtPointEditor”.To create the custom editor for the LookAtPoint script: This is how the Inspector for the LookAtPoint component looks by default: A default Inspector with a public Vector3 fieldĪ custom editor is a separate script which replaces this default layout with any editor controls that you choose. When you place a component on a GameObject, the Inspector displays a default interface that you can use to view and edit every public variable, for example: an integer, a float, or a string. When you create a script in Unity, by default it inherits from MonoBehaviour, and therefore is a component that you can attach to a GameObject. The next step is to create a Custom Editor for the script you just created. The above demonstrates how you can get simple scripts running during edit-time, however this alone does not allow you to create your own Editor tools. More info See in Glossary, the GameObject updates its rotation so that it looks at the target point in world space. Now if you move the GameObject in the Editor, or change the values of “Look At Point” in the Inspector A Unity window that displays information about the currently selected GameObject, asset or project settings, allowing you to inspect and edit the values. To do this, add the ExecuteInEditMode attribute to the class, like this: //C# Example (LookAtPoint.cs) More info See in Glossary, it’s often useful to make certain scripts execute during Edit mode, while your application is not running. When writing Editor scripts A piece of code that allows you to create your own Components, trigger game events, modify Component properties over time and respond to user input in any way you like. When you enter Play mode, the GameObject that you attached the script to now orientates itself towards the coordinates you set to the “Look At Point” property. Public Vector3 lookAtPoint = Vector3.zero In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. Think of each unique Scene file as a unique level. Attach the script to a GameObject in your Scene A Scene contains the environments and menus of your game.Open the script and replace its contents with the code below.Create a C# script and name it "“LookAtPoint”.More info See in Glossary always look at a point.
A GameObject’s functionality is defined by the Components attached to it.
#CUSTOM MAID 3D 2 SAVE EDITOR ONLINE HOW TO#
This page shows you how to create a simple script to make GameObjects The fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. To speed up application development, create custom editors for components you commonly use.