- Home /
Gui Buttons multitouch
I'm developing an Android game. I have 4 GUI buttons on my screen. They are situated in void OnGUI(). So, i have a standard joystick from standard mobile assets. And all i want to do is to let this buttons to be pressed anytime i want. Now I must make a choice: to press a button or to walk using this joystick. I want to do both of these actions at one time. Please, help me with doing that) I tried to read a documentary, but i didn't find something that i need. These documentaries are all about gestures.
void OnGUI(){
//if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began){
if (QCoolDownBtn == false && GUI.Button(new Rect(Screen.width*30/100, Screen.height - Screen.height*1/9 - Screen.width*1/10, Screen.width*1/10, Screen.width*1/10), "Q")){
//QCoolDown = true;
//StartCoroutine(QCoolDownF());
SpellQ = true;
SpellW = false;
SpellE = false;
SpellR = false;
}
if(WCoolDownBtn == false && GUI.Button(new Rect(Screen.width*30/100 + Screen.width*12/100, Screen.height - Screen.height*1/9 - Screen.width*1/10, Screen.width*1/10, Screen.width*1/10), "W")) {
//WCoolDown = true;
//StartCoroutine(WCoolDownF());
SpellQ = false;
SpellW = true;
SpellE = false;
SpellR = false;
}
if(ECoolDownBtn == false && GUI.Button(new Rect(Screen.width*30/100 + Screen.width*24/100, Screen.height - Screen.height*1/9 - Screen.width*1/10, Screen.width*1/10, Screen.width*1/10), "E")){
//ECoolDown = true;
//(ECoolDownF());
SpellQ = false;
SpellW = false;
SpellE = true;
SpellR = false;
}
if(RCoolDownBtn == false && GUI.Button(new Rect(Screen.width*30/100 + Screen.width*36/100, Screen.height - Screen.height*1/9 - Screen.width*1/10, Screen.width*1/10, Screen.width*1/10), "R")){
//RCoolDown = true;
//StartCoroutine(RCoolDownF());
SpellQ = false;
SpellW = false;
SpellE = false;
SpellR = true;
}
}
I can't show you a joystick code because it was was written not by me. I don't know what to paste
Your answer
Follow this Question
Related Questions
Stop clicking through a GUI window 2 Answers
same background image and buttons to work with different apple devices 1 Answer
Automatic Wrap 2 Answers
GameObject touchable instead GUI button 3 Answers
UI Button multiple parameters 6 Answers