damage

Unity自定义Inspectors

好久不见. 提交于 2019-11-26 02:10:59
在Unity中,有时候需要自定义脚本在inspector中的显示,具体操作如下: 1.首先我们要在Editor文件夹下建立一个脚本,范例如下: using UnityEngine; using UnityEditor; using System.Collections; [CustomEditor ( typeof (MyPlayer))] [CanEditMultipleObjects] public class MyPlayerEditor : Editor { SerializedProperty damageProp; SerializedProperty armorProp; SerializedProperty gunProp; void OnEnable () { // Setup the SerializedProperties damageProp = serializedObject.FindProperty ( "damage" ); armorProp = serializedObject.FindProperty ( "armor" ); gunProp = serializedObject.FindProperty ( "gun" ); } public override void OnInspectorGUI () { // Update the