I'm creating a game with a lot of elements. Should I store all components that I'll eventually access on class variables (memory) or should I access them when running the script(processor)?
Example:
private SpriteRenderer sprite;
void Start () {
sprite = GetComponent<SpriteRenderer>();
}
public void StartMovement()
{
sprite.doSomething();
}
VS
void Start () {
}
public void StartMovement()
{
GetComponent<SpriteRenderer>().doSomething();
}