首先创建测试项目:
这里我选择了2D,其实都可以,之后可以在项目中修改。
修改方法:
进入正题。
创建C#脚本文件并打开:
默认的脚本文件为以下格式:
1 using System.Collections; 2 using System.Collections.Generic; 3 using UnityEngine; 4 5 public class TestScript : MonoBehaviour 6 { 7 // Start is called before the first frame update 8 void Start() 9 { 10 11 } 12 13 // Update is called once per frame 14 void Update() 15 { 16 17 } 18 }
Start( )、Update( )都是事件函数。去查一下事件函数有哪些。>事件函数的执行顺序(Order of Execution for Event Function)
这里官方提供了一个叫脚本生命周期流程图(Script lifecycle flowchart)的东西。(PS:好像版本更新导致现在的和以前的不太一样,所以最好跟着官方的文档来。)
那就从事件函数
内容来源于网络如有侵权请私信删除
- 还没有人评论,欢迎说说您的想法!