|
I'm currently using this code so far :
( Found from Unity Script Reference Help ) and it's working for switching the materials on my plane by a timer. I would like to know if there is a way to make this better by making the materials switch with a button such as a Mouse click or just a button press. Even better would be to figure out a way to click on a made button in the game for the "next material" button. The furthest I figure is somehow making a counter. Please help!
(comments are locked)
|
|
i see what you want. ok, here is a script to say that when spacebar is hit to change the material next in the index. if you would like it to be left mouse click then use Fire1 instead of Jump in the script.
hope this help out! Doesn't seem to work for me. I'm trying to avoid GUI's as much as possible since I have no idea how to use them.
Nov 12 '10 at 08:23 PM
Heather
hmm... well i tired the script on a simple box i made and it worked fine. the only thing i can think of is if you didnt add the script to the object you want to change or you forgot to make the size number bigger under the script component and add new materials to it.
Nov 13 '10 at 10:28 PM
JesusChristChangedMe
and if you wanted to change the color by pressing spacebar then you could do if(Input.GetButtonDown("Jump")) { //here you tell it to go to the next material. } ill change my answer to fit what you want.
Nov 13 '10 at 10:31 PM
JesusChristChangedMe
I managed to fix it the way I wanted a couple of days ago. Thanks for your help though, you got me most of the way. :)
Nov 15 '10 at 09:58 PM
Heather
your very welcome! glad you fixed it!
Nov 15 '10 at 10:00 PM
JesusChristChangedMe
(comments are locked)
|
|
Hi I hope this may help http://www.burgzergarcade.com/tutorials/c/dynamically-changing-materials-unity
(comments are locked)
|

OK, to make this simpler, since I don't want to use a Gui....if I use a Input.GetKeyDown button instead...how would I make that??
Something like ..?
function Update() { if(Input.GetKeyDown("a").Button, "Next Material:)?
ok, i fixed my answer, hope it helps!