Скопировал из Scripting Reference (Пунктик Help в Editor'е):
C#
Code
public class example : MonoBehaviour {
public Transform curTransform;
void Start() {
ExampleScript someScript;
someScript = GetComponent<ExampleScript>();
someScript.DoSomething();
}
void Example() {
curTransform = GetComponent<Transform>();
}
}
JavaScript
Code
// Equivalent to: Transform curTransform = transform;
var curTransform : Transform;
curTransform = GetComponent (Transform);
// You can access script components in the same way as other components.
function Start () {
var someScript : ExampleScript;
someScript = GetComponent (ExampleScript);
someScript.DoSomething ();
}