Exemplo n.º 1
0
 internal bool Internal_RaycastRef(Ray ray, ref UIHotSpot.Hit hit)
 {
     float single;
     Vector2 vector2 = new Vector2();
     if (this.radius == 0f)
     {
         return false;
     }
     Plane plane = new Plane(UIHotSpot.forward, this.center);
     if (!plane.Raycast(ray, out single))
     {
         hit = new UIHotSpot.Hit();
         return false;
     }
     hit.point = ray.GetPoint(single);
     hit.normal = (!plane.GetSide(ray.origin) ? UIHotSpot.backward : UIHotSpot.forward);
     vector2.x = hit.point.x - this.center.x;
     vector2.y = hit.point.y - this.center.y;
     float single1 = vector2.x * vector2.x + vector2.y * vector2.y;
     if (single1 >= this.radius * this.radius)
     {
         return false;
     }
     hit.distance = Mathf.Sqrt(single1);
     return true;
 }
Exemplo n.º 2
0
 public static bool GetCentroid(Component cell, out Vector3 centroid)
 {
     if (!(cell is Collider))
     {
         if (!(cell is UIHotSpot))
         {
             UIHotSpot component = cell.GetComponent <UIHotSpot>();
             if (component)
             {
                 centroid = component.worldCenter;
                 return(true);
             }
             Collider collider = cell.collider;
             if (!collider)
             {
                 centroid = Vector3.zero;
                 return(false);
             }
             centroid = collider.bounds.center;
             return(true);
         }
         centroid = ((UIHotSpot)cell).worldCenter;
     }
     else
     {
         centroid = ((Collider)cell).bounds.center;
     }
     return(true);
 }
Exemplo n.º 3
0
 internal bool Internal_RaycastRef(Ray ray, ref UIHotSpot.Hit hit)
 {
     float single;
     Vector2 vector2 = new Vector2();
     if (this.size.x < 2.802597E-45f || this.size.y < 2.802597E-45f)
     {
         return false;
     }
     hit.normal = UIHotSpot.forward;
     Plane plane = new Plane(UIHotSpot.forward, this.center);
     if (!plane.Raycast(ray, out single))
     {
         hit = new UIHotSpot.Hit();
         return false;
     }
     hit.point = ray.GetPoint(single);
     vector2.x = (hit.point.x >= this.center.x ? hit.point.x - this.center.x : this.center.x - hit.point.x);
     vector2.y = (hit.point.y >= this.center.y ? hit.point.y - this.center.y : this.center.y - hit.point.y);
     if (vector2.x * 2f > this.size.x || vector2.y * 2f > this.size.y)
     {
         return false;
     }
     hit.distance = Mathf.Sqrt(vector2.x * vector2.x + vector2.y * vector2.y);
     return true;
 }
Exemplo n.º 4
0
 internal static void UnregisterHotSpot(UIPanel panel, UIHotSpot hotSpot)
 {
     if (((panel.mHotSpots != null) && panel.mHotSpots.Remove(hotSpot)) && panel.enabled)
     {
         hotSpot.OnPanelDisable();
     }
 }
Exemplo n.º 5
0
 internal bool Internal_RaycastRef(Ray ray, ref UIHotSpot.Hit hit)
 {
     float single;
     float single1;
     IntersectHint intersectHint = Intersect3D.RayCircleInfiniteForward(ray, this.center, this.radius, out single, out single1);
     switch (intersectHint)
     {
         case IntersectHint.Touching:
         case IntersectHint.Thru:
         case IntersectHint.Entry:
         {
             hit.distance = Mathf.Min(single, single1);
             if (hit.distance < 0f)
             {
                 float single2 = Mathf.Max(single, single1);
                 float single3 = single2;
                 hit.distance = single2;
                 if (single3 < 0f)
                 {
                     return false;
                 }
             }
             hit.point = ray.GetPoint(hit.distance);
             hit.normal = Vector3.Normalize(hit.point - this.center);
             return true;
         }
     }
     Debug.Log(intersectHint, this);
     return false;
 }
Exemplo n.º 6
0
 internal bool Internal_RaycastRef(Ray ray, ref UIHotSpot.Hit hit)
 {
     Bounds bound = new Bounds(this.center, this.size);
     if (!bound.IntersectRay(ray, out hit.distance))
     {
         return false;
     }
     hit.point = ray.GetPoint(hit.distance);
     hit.normal = -ray.direction;
     return true;
 }
Exemplo n.º 7
0
 internal static void UnregisterHotSpot(UIPanel panel, UIHotSpot hotSpot)
 {
     if (panel.mHotSpots == null || !panel.mHotSpots.Remove(hotSpot))
     {
         return;
     }
     if (panel.enabled)
     {
         hotSpot.OnPanelDisable();
     }
 }
Exemplo n.º 8
0
    public static UIHotSpot AddWidgetHotSpot(GameObject go)
    {
        int    num;
        AABBox aABBox;

        if (go == null)
        {
            return(null);
        }
        Collider collider = go.collider;

        if (collider)
        {
            UIHotSpot hotSpot = NGUITools.ColliderToHotSpot(collider, true);
            if (!hotSpot)
            {
                return(null);
            }
            return(hotSpot);
        }
        UIHotSpot component = go.GetComponent <UIHotSpot>();

        if (component)
        {
            if (component.isRect)
            {
                UIRectHotSpot uIRectHotSpot = component.asRect;
                num                  = NGUITools.CalculateNextDepth(go);
                aABBox               = NGUIMath.CalculateRelativeWidgetBounds(go.transform);
                uIRectHotSpot.size   = aABBox.size;
                uIRectHotSpot.center = aABBox.center + (Vector3.back * ((float)num * 0.25f));
                return(uIRectHotSpot);
            }
            if (!Application.isPlaying)
            {
                UnityEngine.Object.DestroyImmediate(component);
            }
            else
            {
                UnityEngine.Object.Destroy(component);
            }
        }
        num    = NGUITools.CalculateNextDepth(go);
        aABBox = NGUIMath.CalculateRelativeWidgetBounds(go.transform);
        UIRectHotSpot uIRectHotSpot1 = go.AddComponent <UIRectHotSpot>();

        uIRectHotSpot1.size   = aABBox.size;
        uIRectHotSpot1.center = aABBox.center + (Vector3.back * ((float)num * 0.25f));
        return(uIRectHotSpot1);
    }
Exemplo n.º 9
0
    public static UIHotSpot AddWidgetHotSpot(GameObject go)
    {
        int    num;
        AABBox box;

        if (go == null)
        {
            return(null);
        }
        Collider collider = go.collider;

        if (collider != null)
        {
            UIHotSpot spot = ColliderToHotSpot(collider, true);
            if (spot == null)
            {
                return(null);
            }
            return(spot);
        }
        UIHotSpot component = go.GetComponent <UIHotSpot>();

        if (component != null)
        {
            if (component.isRect)
            {
                UIRectHotSpot asRect = component.asRect;
                num           = CalculateNextDepth(go);
                box           = NGUIMath.CalculateRelativeWidgetBounds(go.transform);
                asRect.size   = box.size;
                asRect.center = box.center + ((Vector3)(Vector3.back * (num * 0.25f)));
                return(asRect);
            }
            if (Application.isPlaying)
            {
                UnityEngine.Object.Destroy(component);
            }
            else
            {
                UnityEngine.Object.DestroyImmediate(component);
            }
        }
        num = CalculateNextDepth(go);
        box = NGUIMath.CalculateRelativeWidgetBounds(go.transform);
        UIRectHotSpot spot4 = go.AddComponent <UIRectHotSpot>();

        spot4.size   = box.size;
        spot4.center = box.center + ((Vector3)(Vector3.back * (num * 0.25f)));
        return(spot4);
    }
Exemplo n.º 10
0
    public static bool SetAllowClick(Component self, bool allow)
    {
        Collider collider = self.collider;

        if (collider)
        {
            collider.enabled = allow;
            return(true);
        }
        UIHotSpot component = self.GetComponent <UIHotSpot>();

        if (!component)
        {
            return(false);
        }
        component.enabled = allow;
        return(true);
    }
Exemplo n.º 11
0
 internal static void RegisterHotSpot(UIPanel panel, UIHotSpot hotSpot)
 {
     if (panel.mHotSpots == null)
     {
         panel.mHotSpots = new HashSet <UIHotSpot>();
     }
     if (panel.mHotSpots.Add(hotSpot))
     {
         if (panel.enabled)
         {
             hotSpot.OnPanelEnable();
         }
         else
         {
             hotSpot.OnPanelDisable();
         }
     }
 }
Exemplo n.º 12
0
        public static bool Add(UIHotSpot hotSpot)
        {
            if (hotSpot.index != -1)
            {
                return(false);
            }
            switch (hotSpot.kind)
            {
            case UIHotSpot.Kind.Circle:
                Circle.Add((UICircleHotSpot)hotSpot);
                break;

            case UIHotSpot.Kind.Rect:
                Rect.Add((UIRectHotSpot)hotSpot);
                break;

            case UIHotSpot.Kind.Convex:
                Convex.Add((UIConvexHotSpot)hotSpot);
                break;

            case UIHotSpot.Kind.Sphere:
                Sphere.Add((UISphereHotSpot)hotSpot);
                break;

            case UIHotSpot.Kind.Box:
                Box.Add((UIBoxHotSpot)hotSpot);
                break;

            case UIHotSpot.Kind.Brush:
                Brush.Add((UIBrushHotSpot)hotSpot);
                break;

            default:
                throw new NotImplementedException();
            }
            hotSpot.justAdded = true;
            if (!hotSpot.once)
            {
                hotSpot.HotSpotInit();
                hotSpot.once = true;
            }
            return(true);
        }
Exemplo n.º 13
0
    public static bool GetAllowClick(MonoBehaviour self, out bool possible)
    {
        Collider collider = self.collider;

        if (collider)
        {
            possible = true;
            return(collider.enabled);
        }
        UIHotSpot component = self.GetComponent <UIHotSpot>();

        if (!component)
        {
            possible = false;
            return(false);
        }
        possible = true;
        return(component.enabled);
    }
Exemplo n.º 14
0
        public static bool Remove(UIHotSpot hotSpot)
        {
            if (hotSpot.index == -1)
            {
                return(false);
            }
            switch (hotSpot.kind)
            {
            case UIHotSpot.Kind.Circle:
                Circle.Erase((UICircleHotSpot)hotSpot);
                break;

            case UIHotSpot.Kind.Rect:
                Rect.Erase((UIRectHotSpot)hotSpot);
                break;

            case UIHotSpot.Kind.Convex:
                Convex.Erase((UIConvexHotSpot)hotSpot);
                break;

            case UIHotSpot.Kind.Sphere:
                Sphere.Erase((UISphereHotSpot)hotSpot);
                break;

            case UIHotSpot.Kind.Box:
                Box.Erase((UIBoxHotSpot)hotSpot);
                break;

            case UIHotSpot.Kind.Brush:
                Brush.Erase((UIBrushHotSpot)hotSpot);
                break;

            default:
                throw new NotImplementedException();
            }
            return(true);
        }
Exemplo n.º 15
0
 private void OnClick()
 {
     if (((this.mChild == null) && (this.atlas != null)) && ((this.font != null) && (this.items.Count > 1)))
     {
         this.mLabelList.Clear();
         this.handleEvents = true;
         if (this.mPanel == null)
         {
             this.mPanel = UIPanel.Find(base.transform, true);
         }
         Transform child = base.transform;
         AABBox    box   = NGUIMath.CalculateRelativeWidgetBounds(child.parent, child);
         this.mChild       = new GameObject("Drop-down List");
         this.mChild.layer = base.gameObject.layer;
         Transform transform = this.mChild.transform;
         transform.parent        = child.parent;
         transform.localPosition = box.min;
         transform.localRotation = Quaternion.identity;
         transform.localScale    = Vector3.one;
         this.mBackground        = NGUITools.AddSprite(this.mChild, this.atlas, this.backgroundSprite);
         this.mBackground.pivot  = UIWidget.Pivot.TopLeft;
         this.mBackground.depth  = NGUITools.CalculateNextDepth(this.mPanel.gameObject);
         this.mBackground.color  = this.backgroundColor;
         Vector4 border = this.mBackground.border;
         this.mBgBorder = border.y;
         this.mBackground.cachedTransform.localPosition = new Vector3(0f, border.y, 0f);
         this.mHighlight       = NGUITools.AddSprite(this.mChild, this.atlas, this.highlightSprite);
         this.mHighlight.pivot = UIWidget.Pivot.TopLeft;
         this.mHighlight.color = this.highlightColor;
         UIAtlas.Sprite sprite = this.mHighlight.sprite;
         float          num    = sprite.inner.yMin - sprite.outer.yMin;
         float          num2   = this.font.size * this.textScale;
         float          a      = 0f;
         float          y      = -this.padding.y;
         System.Collections.Generic.List <UILabel> list = new System.Collections.Generic.List <UILabel>();
         int num5  = 0;
         int count = this.items.Count;
         while (num5 < count)
         {
             string  key  = this.items[num5];
             UILabel item = NGUITools.AddWidget <UILabel>(this.mChild);
             item.pivot = UIWidget.Pivot.TopLeft;
             item.font  = this.font;
             item.text  = (!this.isLocalized || (Localization.instance == null)) ? key : Localization.instance.Get(key);
             item.color = this.textColor;
             item.cachedTransform.localPosition = new Vector3(border.x, y, 0f);
             item.MakePixelPerfect();
             if (this.textScale != 1f)
             {
                 Vector3 localScale = item.cachedTransform.localScale;
                 item.cachedTransform.localScale = (Vector3)(localScale * this.textScale);
             }
             list.Add(item);
             y -= num2;
             y -= this.padding.y;
             a  = Mathf.Max(a, item.relativeSize.x * num2);
             UIEventListener listener = UIEventListener.Get(item.gameObject);
             listener.onHover   = new UIEventListener.BoolDelegate(this.OnItemHover);
             listener.onPress   = new UIEventListener.BoolDelegate(this.OnItemPress);
             listener.parameter = key;
             if (this.mSelectedItem == key)
             {
                 this.Highlight(item, true);
             }
             this.mLabelList.Add(item);
             num5++;
         }
         a = Mathf.Max(a, box.size.x - (border.x * 2f));
         Vector3 vector3 = new Vector3((a * 0.5f) / num2, -0.5f, 0f);
         Vector3 vector4 = new Vector3(a / num2, (num2 + this.padding.y) / num2, 1f);
         int     num7    = 0;
         int     num8    = list.Count;
         while (num7 < num8)
         {
             UILabel   label2 = list[num7];
             UIHotSpot spot   = NGUITools.AddWidgetHotSpot(label2.gameObject);
             vector3.z   = spot.center.z;
             spot.center = vector3;
             spot.size   = vector4;
             num7++;
         }
         a += border.x * 2f;
         y -= border.y;
         this.mBackground.cachedTransform.localScale = new Vector3(a, -y + border.y, 1f);
         this.mHighlight.cachedTransform.localScale  = new Vector3((a - (border.x * 2f)) + ((sprite.inner.xMin - sprite.outer.xMin) * 2f), num2 + (num * 2f), 1f);
         bool placeAbove = this.position == Position.Above;
         if (this.position == Position.Auto)
         {
             UICamera camera = UICamera.FindCameraForLayer(base.gameObject.layer);
             if (camera != null)
             {
                 placeAbove = camera.cachedCamera.WorldToViewportPoint(child.position).y < 0.5f;
             }
         }
         if (this.isAnimated)
         {
             float bottom = y + num2;
             this.Animate(this.mHighlight, placeAbove, bottom);
             int num10 = 0;
             int num11 = list.Count;
             while (num10 < num11)
             {
                 this.Animate(list[num10], placeAbove, bottom);
                 num10++;
             }
             this.AnimateColor(this.mBackground);
             this.AnimateScale(this.mBackground, placeAbove, bottom);
         }
         if (placeAbove)
         {
             transform.localPosition = new Vector3(box.min.x, (box.max.y - y) - border.y, box.min.z);
         }
     }
     else
     {
         this.OnSelect(false);
     }
 }
Exemplo n.º 16
0
 internal static void UnregisterHotSpot(UIPanel panel, UIHotSpot hotSpot)
 {
     if (panel.mHotSpots == null || !panel.mHotSpots.Remove(hotSpot))
     {
         return;
     }
     if (panel.enabled)
     {
         hotSpot.OnPanelDisable();
     }
 }
Exemplo n.º 17
0
 private void OnClick()
 {
     if (!(this.mChild == null) || !(this.atlas != null) || !(this.font != null) || this.items.Count <= 1)
     {
         this.OnSelect(false);
     }
     else
     {
         this.mLabelList.Clear();
         this.handleEvents = true;
         if (this.mPanel == null)
         {
             this.mPanel = UIPanel.Find(base.transform, true);
         }
         Transform transforms = base.transform;
         AABBox    aABBox     = NGUIMath.CalculateRelativeWidgetBounds(transforms.parent, transforms);
         this.mChild = new GameObject("Drop-down List")
         {
             layer = base.gameObject.layer
         };
         Transform vector3 = this.mChild.transform;
         vector3.parent         = transforms.parent;
         vector3.localPosition  = aABBox.min;
         vector3.localRotation  = Quaternion.identity;
         vector3.localScale     = Vector3.one;
         this.mBackground       = NGUITools.AddSprite(this.mChild, this.atlas, this.backgroundSprite);
         this.mBackground.pivot = UIWidget.Pivot.TopLeft;
         this.mBackground.depth = NGUITools.CalculateNextDepth(this.mPanel.gameObject);
         this.mBackground.color = this.backgroundColor;
         Vector4 vector4 = this.mBackground.border;
         this.mBgBorder = vector4.y;
         this.mBackground.cachedTransform.localPosition = new Vector3(0f, vector4.y, 0f);
         this.mHighlight       = NGUITools.AddSprite(this.mChild, this.atlas, this.highlightSprite);
         this.mHighlight.pivot = UIWidget.Pivot.TopLeft;
         this.mHighlight.color = this.highlightColor;
         UIAtlas.Sprite sprite   = this.mHighlight.sprite;
         float          single   = sprite.inner.yMin - sprite.outer.yMin;
         float          single1  = (float)this.font.size * this.textScale;
         float          single2  = 0f;
         float          single3  = -this.padding.y;
         List <UILabel> uILabels = new List <UILabel>();
         int            num      = 0;
         int            count    = this.items.Count;
         while (num < count)
         {
             string  item    = this.items[num];
             UILabel uILabel = NGUITools.AddWidget <UILabel>(this.mChild);
             uILabel.pivot = UIWidget.Pivot.TopLeft;
             uILabel.font  = this.font;
             uILabel.text  = (!this.isLocalized || !(Localization.instance != null) ? item : Localization.instance.Get(item));
             uILabel.color = this.textColor;
             uILabel.cachedTransform.localPosition = new Vector3(vector4.x, single3, 0f);
             uILabel.MakePixelPerfect();
             if (this.textScale != 1f)
             {
                 Vector3 vector31 = uILabel.cachedTransform.localScale;
                 uILabel.cachedTransform.localScale = vector31 * this.textScale;
             }
             uILabels.Add(uILabel);
             single3 = single3 - single1;
             single3 = single3 - this.padding.y;
             Vector2 vector2 = uILabel.relativeSize;
             single2 = Mathf.Max(single2, vector2.x * single1);
             UIEventListener boolDelegate = UIEventListener.Get(uILabel.gameObject);
             boolDelegate.onHover   = new UIEventListener.BoolDelegate(this.OnItemHover);
             boolDelegate.onPress   = new UIEventListener.BoolDelegate(this.OnItemPress);
             boolDelegate.parameter = item;
             if (this.mSelectedItem == item)
             {
                 this.Highlight(uILabel, true);
             }
             this.mLabelList.Add(uILabel);
             num++;
         }
         Vector3 vector32 = aABBox.size;
         single2 = Mathf.Max(single2, vector32.x - vector4.x * 2f);
         Vector3 vector33 = new Vector3(single2 * 0.5f / single1, -0.5f, 0f);
         Vector3 vector34 = new Vector3(single2 / single1, (single1 + this.padding.y) / single1, 1f);
         int     num1     = 0;
         int     count1   = uILabels.Count;
         while (num1 < count1)
         {
             UIHotSpot uIHotSpot = NGUITools.AddWidgetHotSpot(uILabels[num1].gameObject);
             vector33.z       = uIHotSpot.center.z;
             uIHotSpot.center = vector33;
             uIHotSpot.size   = vector34;
             num1++;
         }
         single2 = single2 + vector4.x * 2f;
         single3 = single3 - vector4.y;
         this.mBackground.cachedTransform.localScale = new Vector3(single2, -single3 + vector4.y, 1f);
         this.mHighlight.cachedTransform.localScale  = new Vector3(single2 - vector4.x * 2f + (sprite.inner.xMin - sprite.outer.xMin) * 2f, single1 + single * 2f, 1f);
         bool flag = this.position == UIPopupList.Position.Above;
         if (this.position == UIPopupList.Position.Auto)
         {
             UICamera uICamera = UICamera.FindCameraForLayer(base.gameObject.layer);
             if (uICamera != null)
             {
                 Vector3 viewportPoint = uICamera.cachedCamera.WorldToViewportPoint(transforms.position);
                 flag = viewportPoint.y < 0.5f;
             }
         }
         if (this.isAnimated)
         {
             float single4 = single3 + single1;
             this.Animate(this.mHighlight, flag, single4);
             int num2   = 0;
             int count2 = uILabels.Count;
             while (num2 < count2)
             {
                 this.Animate(uILabels[num2], flag, single4);
                 num2++;
             }
             this.AnimateColor(this.mBackground);
             this.AnimateScale(this.mBackground, flag, single4);
         }
         if (flag)
         {
             float   single5  = aABBox.min.x;
             Vector3 vector35 = aABBox.max;
             float   single6  = vector35.y - single3 - vector4.y;
             Vector3 vector36 = aABBox.min;
             vector3.localPosition = new Vector3(single5, single6, vector36.z);
         }
     }
 }
Exemplo n.º 18
0
 internal bool Internal_RaycastRef(Ray ray, ref UIHotSpot.Hit hit)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 19
0
 internal static void RegisterHotSpot(UIPanel panel, UIHotSpot hotSpot)
 {
     if (panel.mHotSpots == null)
     {
         panel.mHotSpots = new HashSet<UIHotSpot>();
     }
     if (panel.mHotSpots.Add(hotSpot))
     {
         if (!panel.enabled)
         {
             hotSpot.OnPanelDisable();
         }
         else
         {
             hotSpot.OnPanelEnable();
         }
     }
 }