/// <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); } } } }
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; } } }; } } }
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; } }
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; } } }; } } }
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)); } }
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)); } }
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)); } }
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)); } }
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)); } }