MonoBehaviour.Start 开始

function Start () : void

Description描述

Start is called just before any of the Update methods is called the first time.

Start仅在Update函数第一次被调用前调用。

Start is only called once in the lifetime of the behaviour. The difference between Awake and Start is that Start is only called if the script instance is enabled. This allows you to delay any initialization code, until it is really needed. Awake is always called before any Start functions. This allows you to order initialization of scripts.

Start在behaviour的生命周期中只被调用一次。它和Awake的不同是Start只在脚本实例被启用时调用。你可以按需调整延迟初始化代码。Awake总是在Start之前执行。这允许你协调初始化顺序。

The Start function is called after all Awake functions on all script instances have been called.

在所有脚本实例中,Start函数总是在Awake函数之后调用。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	private GameObject target;
	void Start() {
		target = GameObject.FindWithTag("Player");
	}
}
// Initializes the target variable.
// target is private and thus not editable in the inspector
// 初始化目标变量
// 目标是私有的并且不能在检视面板中编辑
private var target : GameObject ;

function Start () {
	target = GameObject.FindWithTag ("Player");
}

Page last updated: 2011-1-2