Unity --- OnValidate 和 ExecuteInEditMode

时间:2019-03-27 22:21:35   收藏:0   阅读:353
 1 using UnityEngine;
 2 
 3 [ExecuteInEditMode]  //添加脚本、启动、Stop的时候执行Awake()  Start()
 4 public class test : MonoBehaviour
 5 {
 6     [SerializeField]
 7     int val;
 8     void Awake()
 9     {
10         Debug.Log("Awake()");
11     }
12 
13     void Start()
14     {
15         Debug.Log("Start()");
16     }
17  
18 #if UNITY_EDITOR
19     //启动的时候执行两次,Stop的时候执行一次,组件数值改变的时候执行一次
20     void OnValidate()
21     {
22         Debug.Log("OnValidate()");
23     }
24 #endif
25 
26 }

 

原文:https://www.cnblogs.com/luguoshuai/p/10611190.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!