当前位置:网站首页>Unity 之 ExecuteAlways正在取代ExecuteInEditMode
Unity 之 ExecuteAlways正在取代ExecuteInEditMode
2022-07-05 06:34:00 【陈言必行】
Unity 基础 之 ExecuteAlways介绍
在Unity的编辑器中分为三种模式:
- 编辑器模式:打开任意工程,不做任何操作Unity就处于一个可编辑的状态,这就是编辑器模式;
- 运行模式:当我们点击Play()运行一个场景时,这时Unity就处于运行模式;
- 预制体模式:当Unity进入Prefab时对应的编辑状态叫预制体模式;
ExecuteInEditMode
描述:使脚本的所有实例都在编辑模式下执行。
默认情况下,只在编辑器运行模式下执行 MonoBehaviours。通过添加此属性,MonoBehaviour 的任何实例都将在编辑器处于编辑模式时执行其回调函数。
此属性正在逐步被淘汰,因为它不考虑预制体模式。如果在预制件模式下编辑一个带有 MonoBehaviour 并启用了此属性的预制件,然后进入播放模式,则编辑器将退出预制件模式,以防止由仅用于播放模式的逻辑引起的预制件意外修改。
要指示 MonoBehaviour 正确考虑了预制件模式并且在播放模式期间以预制件模式打开是安全的,可以使用属性 ExecuteAlways 取代此属性。
下面几个函数和运行模式下调用情况不同:
- Update:只有当场景发生变化时才会调用。
- OnGUI:在“游戏视图”接收到非编辑器时调用。事件它不使用(例如,EventType.ScrollWheel)并且不转发到编辑器的键盘快捷方式系统(例如,EventType.KeyDown, EventType.KeyUp)。转发到游戏视图的事件将排队,不能保证立即处理。
- OnRenderObject:在场景视图或游戏视图的每一次重绘上都调用其他呈现回调函数。
ExecuteAlways
使脚本的实例始终执行,作为Play Mode的一部分和Editing。
默认情况下,MonoBehaviours仅在Play Mode下执行。
当希望脚本作为编辑器工作的一部分执行某些操作时,可以使用[ExecuteAlways]属性,该工具不一定与构建
仅在Scene发生改变是调用Update
当Game 试图接收到它不使用的非编辑器事件(例如,EventType.ScrollWheel)会调用OnGUI
在场景试图或者Game试图的每次重绘都会调用OnRenderObject和其他渲染回调函数
边栏推荐
- UIO driven framework
- [Chongqing Guangdong education] National Open University 2018 autumn 0702-22t contemporary Chinese political system reference questions
- How to correctly ask questions in CSDN Q & A
- Error: "mountvolume.setup failed for volume PVC fault handling
- Use ffmpeg to rotate, flip up and down, and flip horizontally
- LSA Type Explanation - lsa-5 (type 5 LSA - autonomous system external LSA) and lsa-4 (type 4 LSA - ASBR summary LSA) explanation
- 将webApp或者H5页面打包成App
- Use the Paping tool to detect TCP port connectivity
- Utf8 encoding
- vsCode创建自己的代码模板
猜你喜欢
安装OpenCV--conda建立虚拟环境并在jupyter中添加此环境的kernel
[algorithm post interview] interview questions of a small factory
UTC, GPS time and Tai
Financial risk control practice -- feature derivation based on time series
cgroup_ memcg
Log4qt usage of logbase in QT project
Vant weapp swippecell set multiple buttons
. Net core stepping on the pit practice
LSA Type Explanation - detailed explanation of lsa-2 (type II LSA network LSA) and lsa-3 (type III LSA network Summary LSA)
5. Oracle tablespace
随机推荐
[Chongqing Guangdong education] 1185t administrative leadership reference test of National Open University in autumn 2018
Vscode configures the typera editor for MD
LSA Type Explanation - lsa-1 [type 1 LSA - router LSA] detailed explanation
How to answer when you encounter a jet on CSDN?
1.手动创建Oracle数据库
LSA Type Explanation - detailed explanation of lsa-2 (type II LSA network LSA) and lsa-3 (type III LSA network Summary LSA)
Vscode creates its own code template
Game theory acwing 892 Steps Nim game
Sum of two numbers, the numbers in the array are converted to decimal, added, and output inversely
Time is fast, please do more meaningful things
[wustctf2020] plain_ WP
The “mode“ argument must be integer. Received an instance of Object
摄像头的MIPI接口、DVP接口和CSI接口
Using handler in a new thread
5.Oracle-錶空間
inux摄像头(mipi接口)简要说明
时间很快,请多做有意义的事情
Positive height system
cgroup_ memcg
微信小程序路由再次跳轉不觸發onload