- Home /
OnTouch Problems :( (C#)
My game is for mobile.
I made a pause button here is the script:
 using UnityEngine;
 using System.Collections;
 
 public class PauseScript : MonoBehaviour {
 
     public GameObject PauseOption;
     public bool paused = false;
 
     static PauseScript myInstance;
     
 
 
     public static PauseScript Instance
     {
         get
         {
             if (myInstance == null)
                 myInstance = FindObjectOfType(typeof(PauseScript)) as PauseScript;
             
             return myInstance;
         }
     }
 
 
 
 
     // Use this for initialization
     void Start () {
     
         PauseOption.SetActive (false);
     }
     
     // Update is called once per frame
     void Update () {
         }
 
     void OnTouchDown (){
         this.transform.localScale = new Vector3 (0.38f, 0.38f, 1);
 
     }
 
     void OnTouchMoved (){
         this.transform.localScale = new Vector3 (0.48f, 0.48f, 1);
         }
     
 
     void OnTouchUp (){
                 this.transform.localScale = new Vector3 (0.48f, 0.48f, 1);
                 PauseOption.SetActive (true);
         
                 if (Time.timeScale == 0) {
                         paused = false;
                         Time.timeScale = 1;
             
             
                 } else {
             
                         paused = true;
                         Time.timeScale = 0;
             
             
                 }
         }
 
     
 }
Is working fine only if I touch it and lift my finger. BUT when I touch it and then drag my finger elsewhere in the screen it just doesn't end the touch phase and my button remains little and there is no pause.
I want to know how do I "CANCEL" the touch phase if my finger goes away from the button.
               Comment
              
 
               
              P.D : I tried solving it with OnTouch$$anonymous$$oved() but it didn't work.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                