当前位置:网站首页>Execution order of scripts bound to game objects

Execution order of scripts bound to game objects

2022-07-06 04:05:00 A plum in fall

1. Can only one script be bound to a game object ?

No , A game object can be bound to multiple scripts .

2. If a game object can bind multiple scripts , So which script executes first ? Which is the last execution ?

First drag the script file onto the game object , Finally, execute ;
Finally, drag to the script file on the game object , The first to perform .

3. If there are multiple game objects in the scene , Script files are bound to multiple game objects , What is the order of execution ?

No matter how many objects there are in the scene , Several scripts are bound to the object
What really determines the order of script execution is : Order of dragging
Drag the script onto the object first , Finally, execute ;
Finally, drag the script onto the object , The first to perform .


summary

Under normal circumstances , The execution order of the script is based on the order of dragging the script to execute the first drag to the object and then execute , After dragging, execute first .
however , There are many script files in actual items , And developers cannot always remember the order of dragging , At this time , You can use interface operations to manage the execution sequence of scripts .
Click on any script file ,Inspector The upper right corner of , There is one order Button
 Insert picture description here

Click on button , choice “+“ No. icon all script files under the current project , Click whichever you need .
 Insert picture description here

Each script item added is followed by a number , The smaller the number is. , Indicates that the script will execute first .
 Insert picture description here

After setting the execution order of the script through the interface , Re execution . Will find , It is based on the order set in the interface .

原网站

版权声明
本文为[A plum in fall]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060401188036.html

随机推荐