Пример #1
0
 // Token: 0x06004AA3 RID: 19107 RVA: 0x00120CA8 File Offset: 0x0011EEA8
 public static bool GetCentroid(Component cell, out Vector3 centroid)
 {
     if (cell is Collider)
     {
         centroid = ((Collider)cell).bounds.center;
     }
     else if (cell is global::UIHotSpot)
     {
         centroid = ((global::UIHotSpot)cell).worldCenter;
     }
     else
     {
         global::UIHotSpot component = cell.GetComponent <global::UIHotSpot>();
         if (component)
         {
             centroid = component.worldCenter;
             return(true);
         }
         Collider collider = cell.collider;
         if (collider)
         {
             centroid = collider.bounds.center;
             return(true);
         }
         centroid = Vector3.zero;
         return(false);
     }
     return(true);
 }
Пример #2
0
 // Token: 0x06004E09 RID: 19977 RVA: 0x00137A30 File Offset: 0x00135C30
 internal static void UnregisterHotSpot(global::UIPanel panel, global::UIHotSpot hotSpot)
 {
     if (panel.mHotSpots == null || !panel.mHotSpots.Remove(hotSpot))
     {
         return;
     }
     if (panel.enabled)
     {
         hotSpot.OnPanelDisable();
     }
 }
Пример #3
0
    // Token: 0x06004A89 RID: 19081 RVA: 0x00120444 File Offset: 0x0011E644
    public static global::UIHotSpot AddWidgetHotSpot(GameObject go)
    {
        if (!(go != null))
        {
            return(null);
        }
        Collider collider = go.collider;

        if (!collider)
        {
            global::UIHotSpot component = go.GetComponent <global::UIHotSpot>();
            int            num;
            global::AABBox aabbox;
            if (component)
            {
                if (component.isRect)
                {
                    global::UIRectHotSpot asRect = component.asRect;
                    num           = global::NGUITools.CalculateNextDepth(go);
                    aabbox        = global::NGUIMath.CalculateRelativeWidgetBounds(go.transform);
                    asRect.size   = aabbox.size;
                    asRect.center = aabbox.center + Vector3.back * ((float)num * 0.25f);
                    return(asRect);
                }
                if (Application.isPlaying)
                {
                    Object.Destroy(component);
                }
                else
                {
                    Object.DestroyImmediate(component);
                }
            }
            num    = global::NGUITools.CalculateNextDepth(go);
            aabbox = global::NGUIMath.CalculateRelativeWidgetBounds(go.transform);
            global::UIRectHotSpot uirectHotSpot = go.AddComponent <global::UIRectHotSpot>();
            uirectHotSpot.size   = aabbox.size;
            uirectHotSpot.center = aabbox.center + Vector3.back * ((float)num * 0.25f);
            return(uirectHotSpot);
        }
        global::UIHotSpot uihotSpot = global::NGUITools.ColliderToHotSpot(collider, true);

        if (!uihotSpot)
        {
            return(null);
        }
        return(uihotSpot);
    }
Пример #4
0
 // Token: 0x06004E08 RID: 19976 RVA: 0x001379E0 File Offset: 0x00135BE0
 internal static void RegisterHotSpot(global::UIPanel panel, global::UIHotSpot hotSpot)
 {
     if (panel.mHotSpots == null)
     {
         panel.mHotSpots = new HashSet <global::UIHotSpot>();
     }
     if (panel.mHotSpots.Add(hotSpot))
     {
         if (panel.enabled)
         {
             hotSpot.OnPanelEnable();
         }
         else
         {
             hotSpot.OnPanelDisable();
         }
     }
 }
Пример #5
0
    // Token: 0x06004A9E RID: 19102 RVA: 0x00120B80 File Offset: 0x0011ED80
    public static bool SetAllowClick(Component self, bool allow)
    {
        Collider collider = self.collider;

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

        if (component)
        {
            component.enabled = allow;
            return(true);
        }
        return(false);
    }
Пример #6
0
    // Token: 0x06004A9F RID: 19103 RVA: 0x00120BC4 File Offset: 0x0011EDC4
    public static bool GetAllowClick(MonoBehaviour self, out bool possible)
    {
        Collider collider = self.collider;

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

        if (component)
        {
            possible = true;
            return(component.enabled);
        }
        possible = false;
        return(false);
    }
Пример #7
0
 // Token: 0x060049CF RID: 18895 RVA: 0x0011B478 File Offset: 0x00119678
 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 = global::UIPanel.Find(base.transform, true);
         }
         Transform      transform = base.transform;
         global::AABBox aabbox    = global::NGUIMath.CalculateRelativeWidgetBounds(transform.parent, transform);
         this.mChild       = new GameObject("Drop-down List");
         this.mChild.layer = base.gameObject.layer;
         Transform transform2 = this.mChild.transform;
         transform2.parent        = transform.parent;
         transform2.localPosition = aabbox.min;
         transform2.localRotation = Quaternion.identity;
         transform2.localScale    = Vector3.one;
         this.mBackground         = global::NGUITools.AddSprite(this.mChild, this.atlas, this.backgroundSprite);
         this.mBackground.pivot   = global::UIWidget.Pivot.TopLeft;
         this.mBackground.depth   = global::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       = global::NGUITools.AddSprite(this.mChild, this.atlas, this.highlightSprite);
         this.mHighlight.pivot = global::UIWidget.Pivot.TopLeft;
         this.mHighlight.color = this.highlightColor;
         global::UIAtlas.Sprite sprite = this.mHighlight.sprite;
         float num  = sprite.inner.yMin - sprite.outer.yMin;
         float num2 = (float)this.font.size * this.textScale;
         float num3 = 0f;
         float num4 = -this.padding.y;
         List <global::UILabel> list = new List <global::UILabel>();
         int i     = 0;
         int count = this.items.Count;
         while (i < count)
         {
             string          text    = this.items[i];
             global::UILabel uilabel = global::NGUITools.AddWidget <global::UILabel>(this.mChild);
             uilabel.pivot = global::UIWidget.Pivot.TopLeft;
             uilabel.font  = this.font;
             uilabel.text  = ((!this.isLocalized || !(global::Localization.instance != null)) ? text : global::Localization.instance.Get(text));
             uilabel.color = this.textColor;
             uilabel.cachedTransform.localPosition = new Vector3(border.x, num4, 0f);
             uilabel.MakePixelPerfect();
             if (this.textScale != 1f)
             {
                 Vector3 localScale = uilabel.cachedTransform.localScale;
                 uilabel.cachedTransform.localScale = localScale * this.textScale;
             }
             list.Add(uilabel);
             num4 -= num2;
             num4 -= this.padding.y;
             num3  = Mathf.Max(num3, uilabel.relativeSize.x * num2);
             global::UIEventListener uieventListener = global::UIEventListener.Get(uilabel.gameObject);
             uieventListener.onHover   = new global::UIEventListener.BoolDelegate(this.OnItemHover);
             uieventListener.onPress   = new global::UIEventListener.BoolDelegate(this.OnItemPress);
             uieventListener.parameter = text;
             if (this.mSelectedItem == text)
             {
                 this.Highlight(uilabel, true);
             }
             this.mLabelList.Add(uilabel);
             i++;
         }
         num3 = Mathf.Max(num3, aabbox.size.x - border.x * 2f);
         Vector3 center;
         center..ctor(num3 * 0.5f / num2, -0.5f, 0f);
         Vector3 size;
         size..ctor(num3 / num2, (num2 + this.padding.y) / num2, 1f);
         int j      = 0;
         int count2 = list.Count;
         while (j < count2)
         {
             global::UILabel   uilabel2  = list[j];
             global::UIHotSpot uihotSpot = global::NGUITools.AddWidgetHotSpot(uilabel2.gameObject);
             center.z         = uihotSpot.center.z;
             uihotSpot.center = center;
             uihotSpot.size   = size;
             j++;
         }
         num3 += border.x * 2f;
         num4 -= border.y;
         this.mBackground.cachedTransform.localScale = new Vector3(num3, -num4 + border.y, 1f);
         this.mHighlight.cachedTransform.localScale  = new Vector3(num3 - border.x * 2f + (sprite.inner.xMin - sprite.outer.xMin) * 2f, num2 + num * 2f, 1f);
         bool flag = this.position == global::UIPopupList.Position.Above;
         if (this.position == global::UIPopupList.Position.Auto)
         {
             global::UICamera uicamera = global::UICamera.FindCameraForLayer(base.gameObject.layer);
             if (uicamera != null)
             {
                 flag = (uicamera.cachedCamera.WorldToViewportPoint(transform.position).y < 0.5f);
             }
         }
         if (this.isAnimated)
         {
             float bottom = num4 + num2;
             this.Animate(this.mHighlight, flag, bottom);
             int k      = 0;
             int count3 = list.Count;
             while (k < count3)
             {
                 this.Animate(list[k], flag, bottom);
                 k++;
             }
             this.AnimateColor(this.mBackground);
             this.AnimateScale(this.mBackground, flag, bottom);
         }
         if (flag)
         {
             transform2.localPosition = new Vector3(aabbox.min.x, aabbox.max.y - num4 - border.y, aabbox.min.z);
         }
     }
     else
     {
         this.OnSelect(false);
     }
 }