Destroy (gameObject, 5); // When the user presses Ctrl, it will remove the script // named FooScript from the game object //当按下Ctrl将从游戏物体删除名为FooScript的脚本 function Update () { if (Input.GetButton ("Fire1") && GetComponent (FooScript)) Destroy (GetComponent (FooScript))...
StartCoroutineStarts a coroutine. StopAllCoroutinesStops all coroutines running on this behaviour. StopCoroutineStops all coroutines named methodName running on this behaviour. GetInstanceIDReturns the instance id of the object. ToStringReturns the name of the game object. ...
StopCoroutineStops all coroutines named methodName running on this behaviour. GetInstanceIDReturns the instance id of the object. ToStringReturns the name of the game object. IsActiveReturns true if the GameObject and the Component are active. ...
OnValidate This function is called when the script is loaded or a value is changed in the Inspector (Called in the editor only). OnWillRenderObject 如果对象可见并且不是 UI 元素,则为每个摄像机调用 OnWillRenderObject。 Reset 重置为默认值。 Start 在首次调用任何 Update 方法之前启用脚本时,在帧上调用...
OnValidateThis function is called when the script is loaded or a value is changed in the Inspector (Called in the editor only). OnWillRenderObject如果对象可见并且不是 UI 元素,则为每个摄像机调用 OnWillRenderObject。 Reset重置为默认值。 Start在首次调用任何 Update 方法之前启用脚本时,在帧上调用 Start...
void Start () { } / Update is called once per frame void Update () { } } //*** Java script *** #pragma strict function Start () { } function Update () { } </span></span> 由此可见,脚本代码与大家熟悉的Java代码类似,即都是由下面两部分组成: • 变量...
// Removes the rigidbody from the game object //从游戏物体删除刚体 Destroy (rigidbody); // Kills the game object in 5 seconds after loading the object //加载物体5秒后销毁游戏物体 Destroy (gameObject, 5); // When the user presses Ctrl, it will remove the script ...
Name of the function in code, including coroutines.publicvoidStopCoroutine(stringmethodName); } } 可以看到,脚本的生命周期函数,如常用的Awake、OnEnable、Start、FixedUpdate、OnTriggerXXX、OnCollisionXXX、Update、LateUpdate、OnGUI、OnDisable、OnDestroy等并不在里面,因为这些函数不是从父类继承然后重写的(也...
void Start () { } / Update is called once per frame void Update () { } } //*** Java script *** #pragma strict function Start () { } function Update () { } </span></span> 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11...
onthisMonoBehaviour.取消这个MonoBehaviour上的所有调用.IsanyinvokeonmethodNamepending?InvokeRepeatingCancelInvokeIsInvoking某指定函数是否在等候调用Startsacoroutine.开始协同程序.StopsallcoroutinesnamedmethodNamerunningonthisbehaviour.停止这个动作中名为methodName的所有协同程序.Stopsallcoroutinesrunningonthisbehaviour....