Hello,
I have a problem with this piece of code:
function Update(){ for (var touch : Touch in Input.touches){ if (guiTexture.HitTest (touch.position)){ guiTexture.color = overColor; if (partClicked == true){ Debug.Log("uit!"); Emitter.GetComponent(ParticleEmitter).emit= false; partClicked = false; } if (partClicked == false){ Debug.Log("aan!"); Emitter.GetComponent(ParticleEmitter).emit= true; partClicked = true; } } } } }
I have a button and when i click on it, i want to turn the particles on, and when i click on it again the particles must go off. This code is attached on a GUI texture.
I know what the problem is (when i touch the button it will execute the 2 “if” commands), so the are always false. And when i keep touching the button it keeps executing the code. How can i make sure that the code is executed only once? no matter how long i keep pressing the button.
tnx in advance!