Here is an small intro of unity initialisation function name start and Awake.
Start
Start function is called only if the script component is enabled.
Start and Awake both are only called once in a lifetime.
Start function is called up after Awake and it execute after the first frame Update.
Below is an example showing start function in unity C# :-
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
private GameObject object;
void Start()
{
object = GameObject.FindWithTag("TestPlayer");
}
}
Awake
Awake function called when the script instance is being loaded.
As we stated above Awake is also called only once during the lifetime of the script instance.
Awake allows you to order initialization of scripts.
Below is an example showing Awake function in unity C# :-
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour
{
private GameObject object;
void Awake()
{
object = GameObject.FindWithTag("TestPlayer");
}
}
0 Comment(s)