コード例 #1
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);
     }
 }