- Home /
How transform Variable is accessed in Scripts ?
My question is about the class hierarchy and API of Unity. I am curious and want to know how "transform" variable is accessed in our scripts by Unity. As all of our scripts are extended from MonoBehaviour Class and I don't found any variable named transform in MonoBehaviour class. I want to know how this variable is accessed when we do this
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour
{
void Update()
{
transform.Translate(Vector3.forward * Time.deltaTime);
}
}
Does anyone from where this transform variables comes ?
Answer by whydoidoit · Jun 19, 2013 at 12:22 PM
transform is a property of MonoBehaviour (not a variable).
Where i can find the list of all properties of $$anonymous$$ono Behaviour ? Because I didn't find them in Scripting Reference
You're right, it appears to be missing, how strange. I think it used to be in there!
Actually it is included in Script Reference - Object>Component>Behaviour>$$anonymous$$onoBehaviour
I can't see it on that page... Am I going word blind ??? (Nor can Ctrl-F find it...)
Answer by JacobK · Jun 19, 2013 at 02:11 PM
Transform is a property of GameObject
http://docs.unity3d.com/Documentation/ScriptReference/GameObject.html
It is also a property of $$anonymous$$onoBehaviour/Behaviour/Component etc not just GameObject.
yes, but our scripts are extended from $$anonymous$$onoBehaviour, not GameObject class
Your answer
Follow this Question
Related Questions
How may i get a variable from another script onto my wanted Script? 1 Answer
script needs to derive from monobehaviour 1 Answer
Monobehavior class variable become null after assigning value when instantiated 1 Answer
new Monobehaviour as variable returns warning... 1 Answer
Accessing gameObject or transform from inside a class 1 Answer