| //-------------------------------------------------------- | 
| //    [Author]:           Mechanist Games | 
| //    [  Date ]:           Wednesday, August 09, 2017 | 
| //-------------------------------------------------------- | 
| using UnityEngine; | 
| using System.Collections; | 
| using UnityEngine.EventSystems; | 
| using System; | 
|   | 
|   | 
|     public class DebugSwitch : MonoBehaviour | 
|     { | 
|   | 
|         public GameObject container; | 
|   | 
|         Vector2 startPosition; | 
|         Vector2 endPosition; | 
|         bool valid = false; | 
|   | 
|         private void LateUpdate() | 
|         { | 
|             if (DebugUtility.Instance.debugAccount) | 
|             { | 
|                 if (Input.GetMouseButtonDown(0)) | 
|                 { | 
|                     if (!RectTransformUtility.RectangleContainsScreenPoint(this.transform as RectTransform, Input.mousePosition, CameraManager.uiCamera)) | 
|                     { | 
|                         startPosition = Input.mousePosition; | 
|                         valid = true; | 
|                     } | 
|                 } | 
|   | 
|                 if (valid) | 
|                 { | 
|                     if (Input.GetMouseButton(0)) | 
|                     { | 
|                         if (RectTransformUtility.RectangleContainsScreenPoint(this.transform as RectTransform, Input.mousePosition, CameraManager.uiCamera)) | 
|                         { | 
|                             endPosition = Input.mousePosition; | 
|                             Trigger(); | 
|                         } | 
|                     } | 
|                 } | 
|             } | 
|   | 
|         } | 
|   | 
|         private void Awake() | 
|         { | 
|             container.SetActive(false); | 
|         } | 
|   | 
|         private void Trigger() | 
|         { | 
|             var gesture = MathUtility.GetGestureDirection(startPosition, endPosition); | 
|             if (gesture == GestureType.Up) | 
|             { | 
|                 container.SetActive(true); | 
|                 valid = false; | 
|             } | 
|         } | 
|   | 
|     } |