- Home /
 
               Question by 
               T. · Mar 20, 2011 at 01:52 AM · 
                textureinstantiateguitexture  
              
 
              Why can't I change the Texture of my GUITexture?
Hey there,
I have an array containing two Texture2Ds, I want to be able to change the Texture2D of the GUITexture that I am instantiating, here is the code I am using:
var n = Random.Range(0,2);
Debug.Log("N : " + n);
var scoreAlert = Instantiate (scoreMessage);
scoreAlert.texture = scoreMessageTexture[n];
However I always receive the error 'texture' is not a member of UnityEngine.Object
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Eric5h5 · Mar 20, 2011 at 02:25 AM
Instantiate returns Object; you need to cast it to GUITexture.
var scoreAlert = Instantiate (scoreMessage) as GUITexture;
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                