- Home /
Question by
Bystry95 · Mar 18, 2016 at 12:34 PM ·
variablestutorialmemory usagetutorials-start-scripting
Is there any performance or memory usage diffrence?
Like in title. Is there ANY major diffrence between these techniques of working at gameObjects ?
public GameObject Player;
(drag & drop png in inspector tab)
Player.transform.postition.x += new Vector2(1,0);
and
GameObject.Find("Player").GetComponent<Transform>.position.x += new Vector2(1,0);
Am I right that first example uses empty variable which is storing dragged and dropped element all the time what causes addictional memory usage? Is it big enough diffrence to take care of it? If I am right then second option is much better becuase it uses only reffrence to already exising gameObject from our scene.
It is really important for me! Thanks for help in advance!
Comment