yyl
2025-06-13 eb1efcaa9be0e2340fc49b38dab8df18e36526c9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//--------------------------------------------------------
//    [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;
            }
        }
 
    }