![]() Shield = serializedObject.FindProperty("shield") WithShield = serializedObject.FindProperty("withShield") MaxHealth = serializedObject.FindProperty("maxHealth") Health = serializedObject.FindProperty("health") Assets/MyGame/Editor/SomethingElse/MyScript.csįor our purpose, I will create a directory tree like this one:Īnd fill HeroEditor.cs with this code: using UnityEditor.It does not matter where the Editor directory or where your script are placed, until the script somewhere inside the hierarchy that contains the Editor directory. In order to create an editor script, you have to put it somewhere inside the Editor directory. Editor scripts are special kinds of scripts that are not included in the build but exist only in the Unity editor. Creating an editor scriptįirst thing you need to do, is to create an editor script. Let’s try to make it more designer-friendly. When With Shield is disabled the Shield property is meaningless.Health cannot be under 0 and above Max Health value.There are few things that we can improve here: The Inspector view of this script will look like this: Let’s consider this script: using UnityEngine All you need to do is to write an editor class with CustomEditor attribute! In fact, Unity gives you complete freedom to choose how you want to display your scripts in the Inspector. You can use decorator attributes but that’s not the only way you can deal with it. ![]() When your scripts are getting bigger, then usually the number of properties is greater too. Unity, by default, is using the most generic way to display these properties because it does not know the context.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |