组件绑定脚本请看:http://blog.csdn.net/tutuboke/article/details/40894433
绑定后,先写脚本,代码如下:
using UnityEngine;
using System.Collections;
public class Test1 : MonoBehaviour {
//变量设置为public 可以再unity3D的编辑器中调节 初值及运行时可能查到值得时时变化
public int i;
public int j;
public int k;
//唤醒一个脚本 第一个执行 执行一次
void Awake(){
Debug.Log ("Awake");
}
// 开始 执行一次
void Start () {
Debug.Log("Start");
}
//绘制界面的 每帧都会调用
void OnGUI()
{
if (k==0)
Debug.Log ("onGui");
k = 1;
}
// 每帧都执行update
void Update () {
if (i == 0)
{
Debug.Log("Update");
}
}
//update函数之后调用 每帧都会调用
void LateUpdate(){
if (i == 0)
{
Debug.Log("LateUpdate");
i = 1;
}
}
//定时调用
//Edit->preject setting ->Time -> (Inspector监测视图)Fixed Timestep 设置刷新时间
void FixedUpdate(){
if (j==0)
Debug.Log("FixedUpdate");
j = 1;
}
//绑定的组件被删除调用
void OnDestroy()
{
Debug.Log("OnDestroy");
}
}
运行u3d ui编辑器,在UI编辑器的左下角查看运行信息及log 出现效果: