- Home /
Touch on GUI.Button HELP!!!!
hey guys a beginner at this so help me out here very little knowledge about unity script but a total freak about games and software's. Anyway what am trying to do is to create a "Reset" button using GUI.Button, the script i came up with (over hours of research) works in a weird way. The button is generated on play and the rest works but works any where i touch on the screen I want it to work only on the GUI.Button. This is an android project.
function OnGUI () {
if (GUI.Button (Rect (0,0,100,50), "Reset")) {
}
}
function Update () {
if(Input.touchCount >= 0) {
var touch : Touch = Input.touches[0];
if(touch.phase == TouchPhase.Began) {
Application.LoadLevel ("112");
}
}
}
Anyone have a better way of creating this reset button would be happy to adopt it....
Answer by JeffreyJo · Nov 23, 2012 at 01:27 PM
Thank you i actually started with that but the touch didn't work the first time as i was using a faulty cell for teasting the app. Thanks guys
Which leads me to another question what am trying to do is make a reset button that will reset the orientation (x,z) of an object back to its original position.
Any ideas on how to do it?? saw many scripts ntn is working out..
Answer by Graham-Dunnett · Nov 23, 2012 at 11:24 AM
Yes, that has been written in a weird way... Try:
function OnGUI () {
if (GUI.Button (Rect (0,0,100,50), "Reset")) {
Application.LoadLevel ("112");
}
}
Answer by DeveshPandey · Nov 23, 2012 at 11:31 AM
I am not exactly what you want to do.
According to my understanding, try the following code it may help you.
if (GUI.Button (Rect (0,0,100,50), "Reset")) {
Application.LoadLevel ("112");
}
if it not help you then clarigy your need, what you want to do?
Your answer
![](https://koobas.hobune.stream/wayback/20220613084355im_/https://answers.unity.com/themes/thub/images/avi.jpg)