- 为一个场景对象添加上三个脚本,在场景开始运行时,脚本中的Start方法将会按照脚本添加的顺序来依次运行,而Update方法却是完全相反
比如:有A1、A2、A3三个脚本,它们的添加顺序是A1、A3、A2,那么在场景运行时,程序运行顺序是A1.Start()、A3.Start()、 A2.Start()、A2.Update()、A3.Update()、A1.Update()……,即使A1.Start()或A2.Update ()运算时间超过其它的方法,那么其它的方法也会等待其运行完成后才会开始运行之……
下面是三个脚本文件的例程:
jxxh01.cs
using UnityEngine; using System.Collections;public class jxxh01 : MonoBehaviour {// Use this for initialization void Start() {for (int temp02 = 0; temp02 < 5; temp02++) { for (int temp01 = 0; temp01 < 5; temp01++) { int a01 = 0; for (int temp = 0; temp < 50000; temp++) { a01++;a = a01; } a01 = 0; } }print(Time.time + " This is jxxh01 : " + a);}public int ForValue=10000;int a = 0;// Update is called once per frame void Update () {for (int temp = 0; temp < ForValue; temp++) { a = temp; } print(Time.time + " This is jxxh01 : " + a);} }
jxxh02.cs
using UnityEngine;using System.Collections;public class jxxh02 : MonoBehaviour{// Use this for initializationvoid Start(){for (int temp = 0; temp < 10000; temp++){a++;}print(Time.time + " This is jxxh02 : " + a);}public int ForValue = 100;int a = 0;// Update is called once per framevoid Update () {print(Time.time + " This is jxxh02 : " + a);}}
jxxh03.cs
using UnityEngine;using System.Collections;public class jxxh03 : MonoBehaviour{// Use this for initializationvoid Start(){for (int temp = 0; temp < 10000; temp++){a++;}print(Time.time + " This is jxxh03 : " + a);}public int ForValue = 100;int a = 0;// Update is called once per framevoid Update () {print(Time.time + " This is jxxh03 : " + a);}}
详细解决方案
unity3d中脚本运行顺序的个人研究
热度:65 发布时间:2024-01-20 03:58:08.0
相关解决方案
- 怎么用 svn 管理 unity3d 项目
- Unity3d Webplayer 障蔽缓存机制
- Unity3d 鼠标捡取 javascript
- unity3d ios开发 调试的流程?该怎么处理
- unity3d ios开发 调试的流程?解决思路
- (转)unity3D iPhone开发有关问题汇总
- Unity3D 搬动平台实现一种大规模(其实跟PC比还是算小规模)动画角色渲染的方案-绝对原创方案。
- Unity3d 播发高质量视频解决方案
- Unity3D 怎么在安卓手机上播放视频
- Android Unity3d 腾挪脚本
- unity3D C#容易代理使用了解
- Delegates, Events and Singletons with Unity3D – C
- UNITY3D c#脚本中处置类与结构体的区别
- Unity3D Shader 入门第一天
- Unity3D 动态加载本地/网络GLB模型
- Unity3D 使用一个AudioSource同时播放背景音乐和按键音效
- Unity3D 如何干净的解除父子关系
- [Unity3D]什么是Apply Root Motion?什么是Bake into Pose?
- Unity3d 中 PlayerPrefs 保存数据的总结
- Unity3D 调用其他函数方法的三种方式
- Unity3D 第一人称相机旋转限制技巧
- Unity3D 文字线条效果
- Unity3D: 动态加载Prefab
- unity3d VR___________通过移动和旋转父物体,来使子物体始终在指定的位置上并且保持指定的角度
- [学习笔记] Unity3D 某些常用类
- [学习笔记]Unity3D 5 引擎------关节(Joint)
- 【转】Unity3d 赛车车辆各类性能算法
- [Unity3D]场景间切换与数据传递(以及物体删除技巧)
- [Unity3D]赛车游戏开发 - 计算机对手AI设计方案
- [Unity3D]开发视图中的标记 - Gizmos