public static dfFontRendererBase Obtain(dfDynamicFont font) { dfDynamicFont.DynamicFontRenderer dynamicFontRenderer = (dfDynamicFont.DynamicFontRenderer.objectPool.Count <= 0 ? new dfDynamicFont.DynamicFontRenderer() : dfDynamicFont.DynamicFontRenderer.objectPool.Dequeue()); dynamicFontRenderer.Reset(); dynamicFontRenderer.Font = font; return(dynamicFontRenderer); }
private dfFontRendererBase obtainRenderer() { Color32?nullable; bool size = base.Size.sqrMagnitude <= 1.401298E-45f; Vector2 vector2 = base.Size - new Vector2((float)this.padding.horizontal, (float)this.padding.vertical); Vector2 vector21 = (this.autoSize || size ? this.getAutoSizeDefault() : vector2); if (this.autoHeight) { vector21 = new Vector2(vector2.x, 2.14748365E+09f); } float units = base.PixelsToUnits(); Vector3 upperLeft = (this.pivot.TransformToUpperLeft(base.Size) + new Vector3((float)this.padding.left, (float)(-this.padding.top))) * units; float textScale = this.TextScale * this.getTextScaleMultiplier(); dfFontRendererBase wordWrap = this.Font.ObtainRenderer(); wordWrap.WordWrap = this.WordWrap; wordWrap.MaxSize = vector21; wordWrap.PixelRatio = units; wordWrap.TextScale = textScale; wordWrap.CharacterSpacing = this.CharacterSpacing; wordWrap.VectorOffset = upperLeft.Quantize(units); wordWrap.MultiLine = true; wordWrap.TabSize = this.TabSize; wordWrap.TabStops = this.TabStops; wordWrap.TextAlign = (!this.autoSize ? this.TextAlignment : UnityEngine.TextAlignment.Left); wordWrap.ColorizeSymbols = this.ColorizeSymbols; wordWrap.ProcessMarkup = this.ProcessMarkup; wordWrap.DefaultColor = (!base.IsEnabled ? base.DisabledColor : base.Color); dfFontRendererBase _dfFontRendererBase = wordWrap; if (!this.enableGradient) { nullable = null; } else { nullable = new Color32?(this.BottomColor); } _dfFontRendererBase.BottomColor = nullable; wordWrap.OverrideMarkupColors = !base.IsEnabled; wordWrap.Opacity = base.CalculateOpacity(); wordWrap.Outline = this.Outline; wordWrap.OutlineSize = this.OutlineSize; wordWrap.OutlineColor = this.OutlineColor; wordWrap.Shadow = this.Shadow; wordWrap.ShadowColor = this.ShadowColor; wordWrap.ShadowOffset = this.ShadowOffset; dfDynamicFont.DynamicFontRenderer atlas = wordWrap as dfDynamicFont.DynamicFontRenderer; if (atlas != null) { atlas.SpriteAtlas = this.Atlas; atlas.SpriteBuffer = this.renderData; } if (this.vertAlign != dfVerticalAlignment.Top) { wordWrap.VectorOffset = this.getVertAlignOffset(wordWrap); } return(wordWrap); }
private dfFontRendererBase obtainTextRenderer() { Vector2 vector = base.Size - new Vector2((float)this.padding.horizontal, (float)this.padding.vertical); Vector2 maxSize = (!this.autoSize) ? MaximumSize : (Vector2.one * 2.14748365E+09f); float num = base.PixelsToUnits(); Vector3 vector2 = (this.pivot.TransformToUpperLeft(base.Size) + new Vector3((float)this.padding.left, (float)(-(float)this.padding.top))) * num; float num2 = this.TextScale * this.getTextScaleMultiplier(); Color32 defaultColor = base.ApplyOpacity(this.getTextColorForState()); dfFontRendererBase dfFontRendererBase = this.Font.ObtainRenderer(); dfFontRendererBase.WordWrap = this.WordWrap; dfFontRendererBase.MultiLine = this.WordWrap; dfFontRendererBase.MaxSize = maxSize; dfFontRendererBase.PixelRatio = num; dfFontRendererBase.TextScale = num2; dfFontRendererBase.CharacterSpacing = 0; int num3 = this.textPixelOffset; if (this.state == dfButton.ButtonState.Hover) { num3 = this.hoverTextPixelOffset; } if (this.state == dfButton.ButtonState.Pressed) { num3 = this.downTextPixelOffset; } if (this.state == dfButton.ButtonState.Disabled) { num3 = this.downTextPixelOffset; } dfFontRendererBase.VectorOffset = vector2.Quantize(num) + new Vector3(0f, (float)num3 * num, 0f); dfFontRendererBase.TabSize = 0; dfFontRendererBase.TextAlign = ((!this.autoSize) ? this.TextAlignment : TextAlignment.Left); dfFontRendererBase.ProcessMarkup = true; dfFontRendererBase.DefaultColor = defaultColor; dfFontRendererBase.OverrideMarkupColors = false; dfFontRendererBase.Opacity = base.CalculateOpacity(); dfFontRendererBase.Shadow = this.Shadow; dfFontRendererBase.ShadowColor = this.ShadowColor; dfFontRendererBase.ShadowOffset = this.ShadowOffset; dfDynamicFont.DynamicFontRenderer dynamicFontRenderer = dfFontRendererBase as dfDynamicFont.DynamicFontRenderer; if (dynamicFontRenderer != null) { dynamicFontRenderer.SpriteAtlas = base.Atlas; dynamicFontRenderer.SpriteBuffer = this.renderData; } if (this.vertAlign != dfVerticalAlignment.Top) { dfFontRendererBase.VectorOffset = this.getVertAlignOffset(dfFontRendererBase); } return(dfFontRendererBase); }
private void renderItems(dfRenderData buffer) { if (this.font == null || this.items == null || (int)this.items.Length == 0) { return; } float units = base.PixelsToUnits(); Vector2 vector2 = new Vector2(this.size.x - (float)this.itemPadding.horizontal - (float)this.listPadding.horizontal, (float)(this.itemHeight - this.itemPadding.vertical)); Vector3 upperLeft = this.pivot.TransformToUpperLeft(base.Size); Vector3 vector3 = new Vector3(upperLeft.x + (float)this.itemPadding.left + (float)this.listPadding.left, upperLeft.y - (float)this.itemPadding.top - (float)this.listPadding.top, 0f) * units; vector3.y = vector3.y + this.scrollPosition * units; Color32 color32 = (!base.IsEnabled ? base.DisabledColor : this.ItemTextColor); float single = upperLeft.y * units; float single1 = single - this.size.y * units; for (int i = 0; i < (int)this.items.Length; i++) { using (dfFontRendererBase itemTextScale = this.font.ObtainRenderer()) { itemTextScale.WordWrap = false; itemTextScale.MaxSize = vector2; itemTextScale.PixelRatio = units; itemTextScale.TextScale = this.ItemTextScale * this.getTextScaleMultiplier(); itemTextScale.VectorOffset = vector3; itemTextScale.MultiLine = false; itemTextScale.TextAlign = this.ItemAlignment; itemTextScale.ProcessMarkup = true; itemTextScale.DefaultColor = color32; itemTextScale.OverrideMarkupColors = false; itemTextScale.Opacity = base.CalculateOpacity(); itemTextScale.Shadow = this.Shadow; itemTextScale.ShadowColor = this.ShadowColor; itemTextScale.ShadowOffset = this.ShadowOffset; dfDynamicFont.DynamicFontRenderer atlas = itemTextScale as dfDynamicFont.DynamicFontRenderer; if (atlas != null) { atlas.SpriteAtlas = base.Atlas; atlas.SpriteBuffer = this.renderData; } if (vector3.y - (float)this.itemHeight * units <= single) { itemTextScale.Render(this.items[i], buffer); } vector3.y = vector3.y - (float)this.itemHeight * units; itemTextScale.VectorOffset = vector3; if (vector3.y < single1) { break; } } } }
private void renderItems(dfRenderData buffer) { if (((this.font != null) && (this.items != null)) && (this.items.Length != 0)) { float num = base.PixelsToUnits(); Vector2 vector = new Vector2((this.size.x - this.itemPadding.horizontal) - this.listPadding.horizontal, (float)(this.itemHeight - this.itemPadding.vertical)); Vector3 vector2 = base.pivot.TransformToUpperLeft(base.Size); Vector3 vector3 = (Vector3)(new Vector3((vector2.x + this.itemPadding.left) + this.listPadding.left, (vector2.y - this.itemPadding.top) - this.listPadding.top, 0f) * num); vector3.y += this.scrollPosition * num; Color32 color = !base.IsEnabled ? base.DisabledColor : this.ItemTextColor; float num2 = vector2.y * num; float num3 = num2 - (this.size.y * num); for (int i = 0; i < this.items.Length; i++) { using (dfFontRendererBase base2 = this.font.ObtainRenderer()) { base2.WordWrap = false; base2.MaxSize = vector; base2.PixelRatio = num; base2.TextScale = this.ItemTextScale * this.getTextScaleMultiplier(); base2.VectorOffset = vector3; base2.MultiLine = false; base2.TextAlign = this.ItemAlignment; base2.ProcessMarkup = true; base2.DefaultColor = color; base2.OverrideMarkupColors = false; base2.Opacity = base.CalculateOpacity(); base2.Shadow = this.Shadow; base2.ShadowColor = this.ShadowColor; base2.ShadowOffset = this.ShadowOffset; dfDynamicFont.DynamicFontRenderer renderer = base2 as dfDynamicFont.DynamicFontRenderer; if (renderer != null) { renderer.SpriteAtlas = base.Atlas; renderer.SpriteBuffer = base.renderData; } if ((vector3.y - (this.itemHeight * num)) <= num2) { base2.Render(this.items[i], buffer); } vector3.y -= this.itemHeight * num; base2.VectorOffset = vector3; if (vector3.y < num3) { break; } } } } }
private dfFontRendererBase obtainRenderer() { bool flag = base.Size.sqrMagnitude <= float.Epsilon; Vector2 vector = base.Size - new Vector2((float)this.padding.horizontal, (float)this.padding.vertical); Vector2 vector2 = (!this.autoSize && !flag) ? vector : this.getAutoSizeDefault(); if (this.autoHeight) { vector2 = new Vector2(vector.x, 2.147484E+09f); } float discreteValue = base.PixelsToUnits(); Vector3 vector3 = (Vector3)((base.pivot.TransformToUpperLeft(base.Size) + new Vector3((float)this.padding.left, (float)-this.padding.top)) * discreteValue); float num2 = this.TextScale * this.getTextScaleMultiplier(); dfFontRendererBase textRenderer = this.Font.ObtainRenderer(); textRenderer.WordWrap = this.WordWrap; textRenderer.MaxSize = vector2; textRenderer.PixelRatio = discreteValue; textRenderer.TextScale = num2; textRenderer.CharacterSpacing = this.CharacterSpacing; textRenderer.VectorOffset = vector3.Quantize(discreteValue); textRenderer.MultiLine = true; textRenderer.TabSize = this.TabSize; textRenderer.TabStops = this.TabStops; textRenderer.TextAlign = !this.autoSize ? this.TextAlignment : UnityEngine.TextAlignment.Left; textRenderer.ColorizeSymbols = this.ColorizeSymbols; textRenderer.ProcessMarkup = this.ProcessMarkup; textRenderer.DefaultColor = !base.IsEnabled ? base.DisabledColor : base.Color; textRenderer.BottomColor = !this.enableGradient ? null : new Color32?(this.BottomColor); textRenderer.OverrideMarkupColors = !base.IsEnabled; textRenderer.Opacity = base.CalculateOpacity(); textRenderer.Outline = this.Outline; textRenderer.OutlineSize = this.OutlineSize; textRenderer.OutlineColor = this.OutlineColor; textRenderer.Shadow = this.Shadow; textRenderer.ShadowColor = this.ShadowColor; textRenderer.ShadowOffset = this.ShadowOffset; dfDynamicFont.DynamicFontRenderer renderer = textRenderer as dfDynamicFont.DynamicFontRenderer; if (renderer != null) { renderer.SpriteAtlas = this.Atlas; renderer.SpriteBuffer = base.renderData; } if (this.vertAlign != dfVerticalAlignment.Top) { textRenderer.VectorOffset = this.getVertAlignOffset(textRenderer); } return(textRenderer); }
private dfFontRendererBase obtainTextRenderer() { Vector2 size = base.Size - new Vector2((float)this.padding.horizontal, (float)this.padding.vertical); Vector2 vector2 = (!this.autoSize ? size : Vector2.one * 2.14748365E+09f); float units = base.PixelsToUnits(); Vector3 upperLeft = (this.pivot.TransformToUpperLeft(base.Size) + new Vector3((float)this.padding.left, (float)(-this.padding.top))) * units; float textScale = this.TextScale * this.getTextScaleMultiplier(); Color32 color32 = base.ApplyOpacity(this.getTextColorForState()); dfFontRendererBase wordWrap = this.Font.ObtainRenderer(); wordWrap.WordWrap = this.WordWrap; wordWrap.MultiLine = this.WordWrap; wordWrap.MaxSize = vector2; wordWrap.PixelRatio = units; wordWrap.TextScale = textScale; wordWrap.CharacterSpacing = 0; wordWrap.VectorOffset = upperLeft.Quantize(units); wordWrap.TabSize = 0; wordWrap.TextAlign = (!this.autoSize ? this.TextAlignment : UnityEngine.TextAlignment.Left); wordWrap.ProcessMarkup = true; wordWrap.DefaultColor = color32; wordWrap.OverrideMarkupColors = false; wordWrap.Opacity = base.CalculateOpacity(); wordWrap.Shadow = this.Shadow; wordWrap.ShadowColor = this.ShadowColor; wordWrap.ShadowOffset = this.ShadowOffset; dfDynamicFont.DynamicFontRenderer atlas = wordWrap as dfDynamicFont.DynamicFontRenderer; if (atlas != null) { atlas.SpriteAtlas = base.Atlas; atlas.SpriteBuffer = this.renderData; } if (this.vertAlign != dfVerticalAlignment.Top) { wordWrap.VectorOffset = this.getVertAlignOffset(wordWrap); } return(wordWrap); }
private void renderText(dfRenderData buffer) { if (this.selectedIndex < 0 || this.selectedIndex >= (int)this.items.Length) { return; } string str = this.items[this.selectedIndex]; float units = base.PixelsToUnits(); Vector2 vector2 = new Vector2(this.size.x - (float)this.textFieldPadding.horizontal, this.size.y - (float)this.textFieldPadding.vertical); Vector3 upperLeft = this.pivot.TransformToUpperLeft(base.Size); Vector3 vector3 = new Vector3(upperLeft.x + (float)this.textFieldPadding.left, upperLeft.y - (float)this.textFieldPadding.top, 0f) * units; Color32 color32 = (!base.IsEnabled ? base.DisabledColor : this.TextColor); using (dfFontRendererBase textScale = this.font.ObtainRenderer()) { textScale.WordWrap = false; textScale.MaxSize = vector2; textScale.PixelRatio = units; textScale.TextScale = this.TextScale; textScale.VectorOffset = vector3; textScale.MultiLine = false; textScale.TextAlign = TextAlignment.Left; textScale.ProcessMarkup = true; textScale.DefaultColor = color32; textScale.OverrideMarkupColors = false; textScale.Opacity = base.CalculateOpacity(); textScale.Shadow = this.Shadow; textScale.ShadowColor = this.ShadowColor; textScale.ShadowOffset = this.ShadowOffset; dfDynamicFont.DynamicFontRenderer atlas = textScale as dfDynamicFont.DynamicFontRenderer; if (atlas != null) { atlas.SpriteAtlas = base.Atlas; atlas.SpriteBuffer = buffer; } textScale.Render(str, buffer); } }
private dfFontRendererBase obtainTextRenderer() { Vector2 vector = base.Size - new Vector2((float)this.padding.horizontal, (float)this.padding.vertical); Vector2 vector2 = !this.autoSize ? vector : ((Vector2)(Vector2.one * 2.147484E+09f)); float discreteValue = base.PixelsToUnits(); Vector3 vector3 = (Vector3)((base.pivot.TransformToUpperLeft(base.Size) + new Vector3((float)this.padding.left, (float)-this.padding.top)) * discreteValue); float num2 = this.TextScale * this.getTextScaleMultiplier(); Color32 color = base.ApplyOpacity(this.getTextColorForState()); dfFontRendererBase textRenderer = this.Font.ObtainRenderer(); textRenderer.WordWrap = this.WordWrap; textRenderer.MultiLine = this.WordWrap; textRenderer.MaxSize = vector2; textRenderer.PixelRatio = discreteValue; textRenderer.TextScale = num2; textRenderer.CharacterSpacing = 0; textRenderer.VectorOffset = vector3.Quantize(discreteValue); textRenderer.TabSize = 0; textRenderer.TextAlign = !this.autoSize ? this.TextAlignment : UnityEngine.TextAlignment.Left; textRenderer.ProcessMarkup = true; textRenderer.DefaultColor = color; textRenderer.OverrideMarkupColors = false; textRenderer.Opacity = base.CalculateOpacity(); textRenderer.Shadow = this.Shadow; textRenderer.ShadowColor = this.ShadowColor; textRenderer.ShadowOffset = this.ShadowOffset; dfDynamicFont.DynamicFontRenderer renderer = textRenderer as dfDynamicFont.DynamicFontRenderer; if (renderer != null) { renderer.SpriteAtlas = base.Atlas; renderer.SpriteBuffer = base.renderData; } if (this.vertAlign != dfVerticalAlignment.Top) { textRenderer.VectorOffset = this.getVertAlignOffset(textRenderer); } return(textRenderer); }