I know that this questions are basic but I didnt find answer using google on my weak mobile, so please dont curse for asking here, on unity answers I didnt get answers, so I hope you will help me here. This is what is my problem. Answer using java script, I dont know c#.
1. Using if else and booleans. I have if else for gui buttons, when u click them variable goes of or on and changes can music be listened:
so it goes like this:
if myboolean == false do actions
myboolean = true;
mystring : music on;
else if myboolean == true do actions
myboolean = false;
mystring: music off;
Problem is that when I click it while false myboolean goes true and else if is also triggered, I have few ideas how to stop it but not sure so far, will using some addition variables help? or should I setting boolean do in next if else, or is there way to stop else if from executing?
2. Slowly fade out gui button: I know if I trigger gui buttons in "if" where is boolean I can make them dissapear instantly but how to do it so they slowly fade out? like what I can do with game objects with alpha channel?
I am sorry for asking basic questions in so bad english but I need help and couldnt find it googling on slow mobile browser hope youi will understand. thank you.
Replies
Your code should be something this:
2. If you want to gradually fade something, you need to make sure that it doesn't run every frame. Something like this could probably work:
You can find more information here:
http://answers.unity3d.com/questions/398855/how-to-make-a-fading-gui-button.html
http://docs.unity3d.com/Documentation/Manual/Coroutines.html