当前位置:网站首页>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和其他渲染回调函数
边栏推荐
- Vant weave swipecell sets multiple buttons
- 扫盲-以太网MII接口类型大全-MII、RMII、SMII、GMII、RGMII、SGMII、XGMII、XAUI、RXAUI
- Rehabilitation type force deduction brush question notes D1
- GDB code debugging
- Database mysql all
- Redis-01. First meet redis
- 1.手动创建Oracle数据库
- 在本地搭建一个微服务集群环境,学习自动化部署
- Architecture
- The problem of Chinese garbled code in the vscode output box can be solved once for life
猜你喜欢

SRE核心体系了解

达梦数据库全部

MPLS experiment

Redis-01. First meet redis

Marvell 88E1515 PHY loopback模式测试

The problem of Chinese garbled code in the vscode output box can be solved once for life

Use ffmpeg to rotate, flip up and down, and flip horizontally

1.手动创建Oracle数据库

Orin two brushing methods

Sre core system understanding
随机推荐
Xavier CPU & GPU high load power consumption test
The problem of Chinese garbled code in the vscode output box can be solved once for life
A brief introduction to heading/pitch/roll and omega/phi/kappa
MPLS experiment
Sre core system understanding
The “mode“ argument must be integer. Received an instance of Object
Skywalking全部
Getting started with typescript
Cloud native related technology learning
How to answer when you encounter a jet on CSDN?
FFmpeg build下载(包含old version)
Edge calculation data sorting
AE tutorial - path growth animation
June 29, 2022 daily
Written examination notes
Orin 两种刷机方式
Game theory acwing 893 Set Nim game
[Chongqing Guangdong education] National Open University 2018 autumn 0702-22t contemporary Chinese political system reference questions
微信小程序路由再次跳轉不觸發onload
2022 winter vacation training game 5