summaryrefslogtreecommitdiff
path: root/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/RaycastResult.cs
blob: 666ef8dd1530efa04da3b022c718671bcdfebe91 (plain)
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
64
65
namespace UnityEngine.EventSystems
{
    // UGUIÉäÏß¼ì²â½á¹û
    public struct RaycastResult
    {
        private GameObject m_GameObject; // Game object hit by the raycast

        public GameObject gameObject
        {
            get { return m_GameObject; }
            set { m_GameObject = value; }
        }

        public BaseRaycaster module; // Event system that hit this object
        public float distance; // The distance from the origin this hit was.
        public float index; // The index this element is in the raycastList (used for sorting)
        public int depth;
        public int sortingLayer;
        public int sortingOrder;
        // World-space position where a ray cast into the screen hits something
        public Vector3 worldPosition;
        // World-space normal where a ray cast into the screen hits something
        public Vector3 worldNormal;

        public Vector2 screenPosition;

        public bool isValid
        {
            get { return module != null && gameObject != null; }
        }

        public void Clear()
        {
            gameObject = null;
            module = null;
            distance = 0;
            index = 0;
            depth = 0;
            sortingLayer = 0;
            sortingOrder = 0;
            worldNormal = Vector3.up;
            worldPosition = Vector3.zero;
            screenPosition = Vector2.zero;
        }

        public override string ToString()
        {
            if (!isValid)
                return "";

            return "Name: " + gameObject + "\n" +
                "module: " + module + "\n" +
                "distance: " + distance + "\n" +
                "index: " + index + "\n" +
                "depth: " + depth + "\n" +
                "worldNormal: " + worldNormal + "\n" +
                "worldPosition: " + worldPosition + "\n" +
                "screenPosition: " + screenPosition + "\n" +
                "module.sortOrderPriority: " + module.sortOrderPriority + "\n" +
                "module.renderOrderPriority: " + module.renderOrderPriority + "\n" +
                "sortingLayer: " + sortingLayer + "\n" +
                "sortingOrder: " + sortingOrder;
        }
    }
}