Game Development Reference
In-Depth Information
OnEnable()
The OnEnable() function is called when an object is enabled and active.
This means that the OnEnable() function will be called every time the object is enabled
and active. This is different from the Start() function, which is only called once for the
object's lifetime.
An example of OnEnable() is as follows:
// JavaScript user:
// Reset object position every time the object is active
function OnEnable () {
transform.position = Vector3.zero;
}
// C# user:
// Reset object position every time the object is active
void OnEnable () {
transform.position = Vector3.zero;
}
Search WWH ::




Custom Search