MonoBehaviour.Start 开始

function Start () : void


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


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.


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


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