// Token: 0x06004C0B RID: 19467 RVA: 0x001296E0 File Offset: 0x001278E0 public global::UIAtlas.Sprite GetSprite(string name) { if (this.mReplacement != null) { return(this.mReplacement.GetSprite(name)); } if (!string.IsNullOrEmpty(name)) { int i = 0; int count = this.sprites.Count; while (i < count) { global::UIAtlas.Sprite sprite = this.sprites[i]; if (!string.IsNullOrEmpty(sprite.name) && name == sprite.name) { return(sprite); } i++; } } else { Debug.LogWarning("Expected a valid name, found nothing"); } return(null); }
// Token: 0x06004A92 RID: 19090 RVA: 0x00120878 File Offset: 0x0011EA78 public static global::UISprite AddSprite(GameObject go, global::UIAtlas atlas, string spriteName) { global::UIAtlas.Sprite sprite = (!(atlas != null)) ? null : atlas.GetSprite(spriteName); global::UISprite uisprite = (sprite != null && !(sprite.inner == sprite.outer)) ? global::NGUITools.AddWidget <global::UISlicedSprite>(go) : global::NGUITools.AddWidget <global::UISprite>(go); uisprite.atlas = atlas; uisprite.spriteName = spriteName; return(uisprite); }
// Token: 0x06004C0C RID: 19468 RVA: 0x00129774 File Offset: 0x00127974 public List <string> GetListOfSprites() { if (this.mReplacement != null) { return(this.mReplacement.GetListOfSprites()); } List <string> list = new List <string>(); int i = 0; int count = this.sprites.Count; while (i < count) { global::UIAtlas.Sprite sprite = this.sprites[i]; if (sprite != null && !string.IsNullOrEmpty(sprite.name)) { list.Add(sprite.name); } i++; } list.Sort(); return(list); }
// Token: 0x060049C5 RID: 18885 RVA: 0x0011AFB4 File Offset: 0x001191B4 private void Highlight(global::UILabel lbl, bool instant) { if (this.mHighlight != null) { global::TweenPosition component = lbl.GetComponent <global::TweenPosition>(); if (component != null && component.enabled) { return; } this.mHighlightedLabel = lbl; global::UIAtlas.Sprite sprite = this.mHighlight.sprite; float num = sprite.inner.xMin - sprite.outer.xMin; float num2 = sprite.inner.yMin - sprite.outer.yMin; Vector3 vector = lbl.cachedTransform.localPosition + new Vector3(-num, num2, 0f); if (instant || !this.isAnimated) { this.mHighlight.cachedTransform.localPosition = vector; } else { global::TweenPosition.Begin(this.mHighlight.gameObject, 0.1f, vector).method = global::UITweener.Method.EaseOut; } } }
// Token: 0x06004E66 RID: 20070 RVA: 0x00143654 File Offset: 0x00141854 private void RebuildSpriteList() { if (this.mSprite == null) { this.mSprite = base.GetComponent <global::UISprite>(); } this.mSpriteNames.Clear(); if (this.mSprite != null && this.mSprite.atlas != null) { List <global::UIAtlas.Sprite> spriteList = this.mSprite.atlas.spriteList; int i = 0; int count = spriteList.Count; while (i < count) { global::UIAtlas.Sprite sprite = spriteList[i]; if (string.IsNullOrEmpty(this.mPrefix) || sprite.name.StartsWith(this.mPrefix)) { this.mSpriteNames.Add(sprite.name); } i++; } this.mSpriteNames.Sort(); } }
// 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); } }