当前位置:网站首页>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和其他渲染回调函数
边栏推荐
- AE tutorial - path growth animation
- LSA Type Explanation - detailed explanation of lsa-2 (type II LSA network LSA) and lsa-3 (type III LSA network Summary LSA)
- RecyclerView的应用
- Application of recyclerview
- Chinese remainder theorem acwing 204 Strange way of expressing integers
- Volcano resource reservation feature
- MySQL (UDF authorization)
- 5.Oracle-表空间
- Orin installs CUDA environment
- 3.Oracle-控制文件的管理
猜你喜欢
‘mongoexport‘ 不是内部或外部命令,也不是可运行的程序 或批处理文件。
安装OpenCV--conda建立虚拟环境并在jupyter中添加此环境的kernel
摄像头的MIPI接口、DVP接口和CSI接口
Find the combination number acwing 887 Find combination number III
LSA Type Explanation - lsa-1 [type 1 LSA - router LSA] detailed explanation
Package webapp or H5 pages into apps
Vscode configures the typera editor for MD
Install opencv -- CONDA to establish a virtual environment and add the kernel of this environment in jupyter
. Net core stepping on the pit practice
1.手动创建Oracle数据库
随机推荐
Marvell 88E1515 PHY loopback模式测试
H5 模块悬浮拖动效果
Stack acwing 3302 Expression evaluation
Marvell 88e1515 PHY loopback mode test
Paper reading report
Sre core system understanding
Package webapp or H5 pages into apps
ollvm编译出现的问题纪录
【MySQL8.0不支持表名大写-对应方案】
Vscode configures the typera editor for MD
2022-5-第四周日报
How to correctly ask questions in CSDN Q & A
5. Oracle tablespace
ADG5412FBRUZ-RL7应用 双电源模拟开关和多路复用器IC
Vscode creates its own code template
SRE核心体系了解
2048 project realization
[moviepy] unable to find a solution for exe
Architecture
Game theory acwing 894 Split Nim game