- Home /
how to add material component to an Animate GUI script
Essentially I'm trying to create a cursor with two textures which it will alternate between using scripting but I can't seem to add a texture component in the Animate GUI script in the inspector window. Any suggestions as to how to accomplish this?
(By the way I'm trying to follow this tutorial: http://www.design3.com/unity/game-builds/knights-3d-game/item/315-chapter-4-custom-cursor-image)
I think this may have to do with the script the tutorial is using that no longer works (specifically the Textured2D)?
(below is my animate GUI script so far)
var textures : Textures2D[];
function Update () { if (Input.GetButton("Fire1") ) { guiTexture.texture = textures[1]; } else { guiTexture.texture = texture [0]; } }
@script RequireComponent(GUITexture)
The only thing I'm seeing wrong with this script is a few misspelled words:
var textures : Texture2D[]; //removed an extra s on the Texture2D
else{ ... = textures[0];//added a missing s to textures
I would assume the compiler would catch those so I don't think this is what you're looking for, though
Answer by Ashkan_gc · Jun 26, 2011 at 05:26 PM
you should write
var textures : Texture2d;
and not Textures2d. this is the problem. then use textures[n] where n is the index of the texture in the texture array.
Oh thank you. That did fix my script error.
However I still don't have a material component under my GUIscript that I need...
you don't need a material component. you now have an array called textures in your inspector. open it and type a number is size filed (2 for example) and then drag two textures in those two appeared texture slots. and use them.
Your answer
Follow this Question
Related Questions
Editing buttons created in 'for' loop. 0 Answers
GetComponent Help 2 Answers
GUI in the middle of the screen 1 Answer
GUI draw rectangle script not drawing rectangle! 1 Answer
Any/best way to add a texture in Editor? 2 Answers