• Inspector视图中的get/set使用


    using UnityEngine;
    using System.Collections;
    
    public class Test : MonoBehaviour {
    
        public int width
        {
            get {
                Debug.Log("get");
                return _width; 
            }
            set {
                Debug.Log ("set");
                _width = value; 
            }
        }
        [SerializeField]//强制Unity去序列化一个私有域
        private int _width;
    }
    using UnityEngine;
    using System.Collections;
    using UnityEditor;
    
    [CustomEditor(typeof(Test))]
    public class TestEditor:Editor {
        
        public override void OnInspectorGUI (){
            Test test=target as Test;
            int w=EditorGUILayout.IntField("Width",test.width);
            if(test.width!=w)test.width=w;
    
            base.OnInspectorGUI ();
        }
    }
  • 相关阅读:
    JSP第三章
    JSP第二章
    JSP第一章
    异常
    七种设计原则
    非泛型集合
    .NET第一章
    航班预定系统
    JSP数据交互(二)
    JSP数据交互(一)
  • 原文地址:https://www.cnblogs.com/kingBook/p/6309028.html
Copyright © 2020-2023  润新知