示例#1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="value"></param>
 public void SetHitTestMode(HitTestMode value)
 {
     if (this.hitTestMode != value)
     {
         this.hitTestMode = value;
         BoxCollider collider = this.gameObject.GetComponent <BoxCollider>();
         if (this.hitTestMode == HitTestMode.Raycast)
         {
             if (collider == null)
             {
                 collider = this.gameObject.AddComponent <BoxCollider>();
             }
             ColliderHitTest hitArea = new ColliderHitTest();
             hitArea.collider       = collider;
             this.container.hitArea = hitArea;
             if (_ui != null)
             {
                 UpdateHitArea();
             }
         }
         else
         {
             this.container.hitArea = null;
             if (collider != null)
             {
                 Component.Destroy(collider);
             }
         }
     }
 }
示例#2
0
        void CreateContainer()
        {
            if (!Application.isPlaying)
            {
                Transform t   = this.transform;
                int       cnt = t.childCount;
                while (cnt > 0)
                {
                    GameObject go = t.GetChild(cnt - 1).gameObject;
                    if (go.name == "UI(AutoGenerated)")
                    {
#if (UNITY_2018_3_OR_NEWER && UNITY_EDITOR)
                        if (PrefabUtility.IsPartOfPrefabInstance(go))
                        {
                            PrefabUtility.UnpackPrefabInstance(PrefabUtility.GetOutermostPrefabInstanceRoot(gameObject), PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);
                        }
#endif
                        UnityEngine.Object.DestroyImmediate(go);
                    }
                    cnt--;
                }
            }

            this.container               = new Container(this.gameObject);
            this.container.renderMode    = renderMode;
            this.container.renderCamera  = renderCamera;
            this.container.touchable     = !touchDisabled;
            this.container._panelOrder   = sortingOrder;
            this.container.fairyBatching = fairyBatching;
            if (Application.isPlaying)
            {
                SetSortingOrder(this.sortingOrder, true);
                if (this.hitTestMode == HitTestMode.Raycast)
                {
                    ColliderHitTest hitArea = new ColliderHitTest();
                    hitArea.collider       = this.gameObject.AddComponent <BoxCollider>();
                    this.container.hitArea = hitArea;
                }

                if (setNativeChildrenOrder)
                {
                    CacheNativeChildrenRenderers();

                    this.container.onUpdate += () =>
                    {
                        int cnt = _renders.Count;
                        int sv  = UpdateContext.current.renderingOrder++;
                        for (int i = 0; i < cnt; i++)
                        {
                            Renderer r = _renders[i];
                            if (r != null)
                            {
                                _renders[i].sortingOrder = sv;
                            }
                        }
                    };
                }
            }
        }
示例#3
0
        void UpdateHitArea()
        {
            ColliderHitTest hitArea = this.container.hitArea as ColliderHitTest;

            if (hitArea != null)
            {
                ((BoxCollider)hitArea.collider).center = new Vector3(_ui.xMin + _ui.width / 2, -_ui.yMin - _ui.height / 2);
                ((BoxCollider)hitArea.collider).size   = _ui.size;
            }
        }
示例#4
0
        void CreateContainer()
        {
            if (!Application.isPlaying)
            {
                Transform t   = this.transform;
                int       cnt = t.childCount;
                while (cnt > 0)
                {
                    GameObject go = t.GetChild(cnt - 1).gameObject;
                    if (go.name == "UI(AutoGenerated)")
                    {
                        UnityEngine.Object.DestroyImmediate(go);
                    }
                    cnt--;
                }
            }

            this.container               = new Container(this.gameObject);
            this.container.renderMode    = renderMode;
            this.container.renderCamera  = renderCamera;
            this.container.touchable     = !touchDisabled;
            this.container._isPanel      = true;
            this.container._panelOrder   = sortingOrder;
            this.container.fairyBatching = fairyBatching;
            if (Application.isPlaying)
            {
                SetSortingOrder(this.sortingOrder, true);
                if (this.hitTestMode == HitTestMode.Raycast)
                {
                    ColliderHitTest hitArea = new ColliderHitTest();
                    hitArea.collider       = this.gameObject.AddComponent <BoxCollider>();
                    this.container.hitArea = hitArea;
                }

                if (setNativeChildrenOrder)
                {
                    CacheNativeChildrenRenderers();

                    this.container.onUpdate = () =>
                    {
                        int cnt = _renders.Count;
                        int sv  = UpdateContext.current.renderingOrder++;
                        for (int i = 0; i < cnt; i++)
                        {
                            Renderer r = _renders[i];
                            if (r != null)
                            {
                                _renders[i].sortingOrder = sv;
                            }
                        }
                    };
                }
            }
        }
示例#5
0
 static public int get_collider(IntPtr l)
 {
     try {
         FairyGUI.ColliderHitTest self = (FairyGUI.ColliderHitTest)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.collider);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#6
0
 static public int set_collider(IntPtr l)
 {
     try {
         FairyGUI.ColliderHitTest self = (FairyGUI.ColliderHitTest)checkSelf(l);
         UnityEngine.Collider     v;
         checkType(l, 2, out v);
         self.collider = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#7
0
 static public int SetEnabled(IntPtr l)
 {
     try {
         FairyGUI.ColliderHitTest self = (FairyGUI.ColliderHitTest)checkSelf(l);
         System.Boolean           a1;
         checkType(l, 2, out a1);
         self.SetEnabled(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#8
0
 static public int HitTest(IntPtr l)
 {
     try {
         FairyGUI.ColliderHitTest self = (FairyGUI.ColliderHitTest)checkSelf(l);
         FairyGUI.Container       a1;
         checkType(l, 2, out a1);
         UnityEngine.Vector2 a2;
         checkType(l, 3, out a2);
         var ret = self.HitTest(a1, ref a2);
         pushValue(l, true);
         pushValue(l, ret);
         pushValue(l, a2);
         return(3);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#9
0
 static public int SetArea(IntPtr l)
 {
     try {
         FairyGUI.ColliderHitTest self = (FairyGUI.ColliderHitTest)checkSelf(l);
         System.Single            a1;
         checkType(l, 2, out a1);
         System.Single a2;
         checkType(l, 3, out a2);
         System.Single a3;
         checkType(l, 4, out a3);
         System.Single a4;
         checkType(l, 5, out a4);
         self.SetArea(a1, a2, a3, a4);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }