GetComponent
or FindObject
). What is the difference and Which situation one of those would be preferred?A.
pros of drag & drop:
- easily can be seen.
- simple to check null via validation tool
- these tasks can be done in graphic team
cons of drag & drop:
- be carefull when treating
*.meta
files
pros of invoking from code:
- easy to manage via dynamic allocating
- advantage comes from the team project (sharing with git)
cons of invoking from code:
- should be awake on the Unity life cycle.(null error occurs with the order of invokes)
Indeed, the difference of performance is pretty small. The adoption is on the user.
Action
and event Action
in Unity?A. Similar with the difference of field and property, the event would be act as the instead of getter & setter. For instance, the variable can be written like below
float testVariable1; // field
float testVariable2 // property
{
get;
set;
}
Action testAction1; // Action
event Action testAction2 // event Action
{
add{}
remove{}
}