guitexture a static var?

can a guitexture be a static var? I am trying to access a guitexture that in in another js file. I made it a static variable but am not having any luck. Is this even possible?

Why don't you just get its reference from the other Game Object?

// C#
GUITexture gt = GameObject.FindObjectOfType(typeof(GUITexture)) as GUITexture;
gt.DoSomething(); // whatever you want here

(Note that that code should NOT be placed inside of an Update() function, and will ONLY find the first GUITexture you have.)

Or, instead of using FindObjectOfType(), you could also:

  • Find the game object by name
  • Find the game object by type
  • Store a reference to the game object at design-time, by including `public GameObject myObject;` Then, fill it in in the Inspector.

Then, you could just get the component from the game object like so:

// C#
GameObject go; // make this reference your target game object somehow
GUITexture gt = go.GetComponent(typeof(GUITexture)) as GUITexture;
gt.DoSomething(); // whatever you want here

var myGUI: GUITexture=gameObject.GetComponent(GUITexture);