Game Development Reference
In-Depth Information
Start()
The
Start()
function is called just before any of the
Update()
methods is called.
Start()
is only called once in the lifetime of the behavior. 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 of code until it is really needed.
The
Start()
function is called after all
Awake()
functions on all script instances have
been called. An example of the
Start()
function is as follows:
// JavaScript user:
private var myLife : int;
function Start() {
myLife = 5;
}
// C# user:
int myLife;
void Start() {
myLife = 5;
}