Logic of Unity 5 GetComponent

Hello! I just try to understand why it was needed (or why new method is better):

  • in Unity 4.6 we was able to do something like

this.rigidbody2D.velocity = ....

  • but in Unity 5 we need write

shipRigidbody = GetComponent();
and only after this we can use rigidbody2D component.

Or (another exanple from this project)

audio.Play
rigidbody2D.velocity += tweak

look shorter and much more readuble then

GetComponent<AudioSource>().Play();
GetComponent<Rigidbody2D>().velocity() += tweak;

Why these changes was maded in Unity-5? They must have a sence.

Privacy & Terms