Hello,
I downloaded and listened to some of the Unity presentations and one of these was about decoupling your code. In this they talked about not reference gameobject and such any more. If i understood this correctly, that is. So I’m trying to figure out a different way of accessing components that i need.
What’s considered good practice?
Components that have properties defined in MonoBehaviour (like transform, etc) actually call some code behind the scenes when they are used. You can save a bit of CPU overhead by accessing the property once and then storing a reference to it in a variable:-
var trans: Transform;
function Start() {
trans = transform;
}
function Update() {
// Code that uses trans instead of transform.
}
This will typically not make much difference, but it might if you refer to the transform within a loop in the Update function, say.