(编辑状态下)Reset及OnValidate使用

using UnityEngine;
using System.Collections;

public class Demo : MonoBehaviour {

#if UNITY_EDITOR
    void Reset()
    {
        Debug.Log("把脚本添加到某个物体上就会执行,之后再按物体右上角小三角弹出对话框里的reset也会执行。");
    }
    void OnValidate()
    {
        Debug.Log("脚本被修改了之后就会执行");
    }
#endif

}
原文地址:https://www.cnblogs.com/Feiyuzhu/p/5688209.html