Unity3d 扩展自定义类Inspector

public class MyClass : MonoBehaviour {

    public int A;

    // Use this for initialization
void Start () { } // Update is called once per frame
void Update () { }
}
using UnityEngine;
using System.Collections;
using UnityEditor; [CanEditMultipleObjects()]
[CustomEditor(typeof(MyClass), true)]
public class MyClassEditor : Editor
{ SerializedProperty A; // Use this for initialization
void Start () { } void OnEnable()
{
this.A = base.serializedObject.FindProperty("A");
} // Update is called once per frame
public override void OnInspectorGUI()
{
//base.DrawDefaultInspector(); serializedObject.Update(); EditorGUILayout.PropertyField(A); EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("Set 10", GUILayout.Width(60)))
{
(target as MyClass).A = 10;
} else if (GUILayout.Button("Set 20", GUILayout.Width(60)))
{
(target as MyClass).A = 20;
}
EditorGUILayout.EndHorizontal();
}
}

  

上一篇:Windows 程序注册成服务的方法


下一篇:跨域的案例 以百度接口/手写接口为例,还有jQuery写法