let's say that inside an OnGUI() script we want to call a method from another script to handle a particular situation. From a prestational point of view, what's the difference between these 3 approaches?
1.
public class SomeClass : MonoBehaviour{
...
void OnGUI(){
if(something)
otherClass.heavyWorkMethod();
...
}
}
2.
public class SomeClassCoroutine : MonoBehavior{
...
void OnGUI(){
if(something)
StartCoroutine("someClassCoroutine");
...
}
IEnumerator someClassCoroutine(){
otherClass.heavyWorkMethod();
...
}
}
3.
public class SomeClassEvent : MonoBehavior{
public delegate void SomeAction();
public static event SomeAction OnEvent;
...
void OnGUI(){
if(something)
OnEvent();
}
}
Where in the third case, the heavyWorkMethod in OtherClass gets called when the event OnEvent is fired.
Thanks for your time. Looking forward to read your answers.