public class Test : MonoBehaviour {
public string name;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
#if UNITY_EDITOR
void Reset(){
Debug.Log ("add Scripts");
}
void OnValidate(){
Debug.Log ("Changed");
}
public string name;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
#if UNITY_EDITOR
void Reset(){
Debug.Log ("add Scripts");
}
void OnValidate(){
Debug.Log ("Changed");
}
#endif
}
1.图中的“齿轮”点击后会有“Reset”选项
2.当把代码放到GameObject中
这些时候会调用Reset函数
1.当改变代码中的变量
2.当修改其他的代码,Unity编辑完成后
这些时候会调用OnValidate函数