protected void _Create(EleBaseRect parent, string text, Font font, Color fontColor, int fontPointSize, Sprite frame, PadRect padding, Vector2 size, string name) { GameObject goPlate = new GameObject("HeaderPlate_" + name); goPlate.transform.SetParent(parent.GetContentRect()); this.plate = goPlate.AddComponent <UnityEngine.UI.Image>(); this.plate.rectTransform.RTQ().Identity().TopLeftAnchorsPivot().ZeroOffsets(); this.plate.sprite = frame; this.plate.type = UnityEngine.UI.Image.Type.Sliced; this.border = padding; GameObject goText = new GameObject("HeaderText_" + name); goText.transform.SetParent(this.plate.rectTransform); this.text = goText.AddComponent <UnityEngine.UI.Text>(); this.text.rectTransform.RTQ().Identity().TopLeftAnchorsPivot().ZeroOffsets(); this.text.font = font; this.text.color = fontColor; this.text.fontSize = fontPointSize; this.text.text = text; }
public static PxPre.UIL.EleBoxSizer Chn_Border(this PxPre.UIL.EleBoxSizer szr, PxPre.UIL.PadRect pr) { szr.border = pr; return(szr); }
protected void _Create(EleBaseRect parent, string text, Font font, Color fontColor, int pointSize, bool multiline, Sprite plate, PadRect padding, Vector2 size, string name) { this.border = padding; GameObject go = new GameObject("InputPlate_" + name); go.transform.SetParent(parent.GetContentRect(), false); go.transform.localRotation = Quaternion.identity; go.transform.localScale = Vector3.one; UnityEngine.UI.Image img = go.AddComponent <UnityEngine.UI.Image>(); img.RTQ().TopLeftAnchorsPivot(); img.sprite = plate; img.type = UnityEngine.UI.Image.Type.Sliced; GameObject goInput = new GameObject("Input_" + name); goInput.transform.SetParent(go.transform, false); this.rtInput = goInput.AddComponent <RectTransform>(); this.rtInput.pivot = new Vector2(0.0f, 1.0f); this.rtInput.anchorMin = Vector2.zero; this.rtInput.anchorMax = Vector2.one; this.rtInput.offsetMin = new Vector2(padding.left, padding.bot); this.rtInput.offsetMax = new Vector2(-padding.right, -padding.top); GameObject goText = new GameObject("InputText_" + name); goText.transform.SetParent(this.rtInput, false); goText.transform.localRotation = Quaternion.identity; goText.transform.localPosition = Vector3.zero; UnityEngine.UI.Text txt = goText.AddComponent <UnityEngine.UI.Text>(); txt.RTQ().TopLeftAnchorsPivot().ExpandParentFlush(); GameObject goPlaceholder = new GameObject("InputPlaceholder_" + name); goPlaceholder.transform.SetParent(this.rtInput, false); goPlaceholder.transform.localRotation = Quaternion.identity; goPlaceholder.transform.localPosition = Vector3.zero; UnityEngine.UI.Text txtPlace = goPlaceholder.AddComponent <UnityEngine.UI.Text>(); txtPlace.RTQ().TopLeftAnchorsPivot().ExpandParentFlush(); this.input = goInput.AddComponent <UnityEngine.UI.InputField>(); this.input.textComponent = txt; this.input.targetGraphic = img; this.input.placeholder = txtPlace; this.rt = go.GetComponent <RectTransform>(); this.placeholder = txtPlace; this.text = txt; this.text.color = fontColor; this.text.font = font; this.text.fontSize = pointSize; this.text.verticalOverflow = VerticalWrapMode.Overflow; this.placeholder.color = new Color(fontColor.r, fontColor.g, fontColor.b, fontColor.a * 0.5f); this.placeholder.font = font; this.placeholder.fontSize = pointSize; this.placeholder.verticalOverflow = VerticalWrapMode.Overflow; this.input.lineType = multiline ? UnityEngine.UI.InputField.LineType.MultiLineNewline : UnityEngine.UI.InputField.LineType.SingleLine; if (multiline == false) { this.text.alignment = TextAnchor.MiddleLeft; this.placeholder.alignment = TextAnchor.MiddleLeft; } }
public EleInput(EleBaseRect parent, string text, Font font, Color fontColor, int pointSize, bool multiline, Sprite plate, PadRect padding, Vector2 size, string name = "") : base(parent, size, name) { this._Create( parent, text, font, fontColor, pointSize, multiline, plate, padding, size, name); }
protected void _Create( EleBaseRect parent, TextAttrib textAttrib, string text, SelectableInfo plateStyle, float toggleWidth, Sprite toggleSprite, UnityEngine.UI.Image.Type icoType, PadRect togglePad, Vector2 size, float separation, string name) { this.minSize = size; this.separation = separation; this.toggleWidth = toggleWidth; this.padding = togglePad; GameObject go = new GameObject("Checkbox_" + name); go.transform.SetParent(parent.GetContentRect(), false); // this.plate = go.AddComponent <UnityEngine.UI.Image>(); this.plate.type = UnityEngine.UI.Image.Type.Sliced; this.plate.RTQ().TopLeftAnchorsPivot(); // this.toggle = go.AddComponent <ty>(); plateStyle.Apply(this.toggle, this.plate); GameObject goCheckmark = new GameObject("Checkmark_" + name); goCheckmark.transform.SetParent(go.transform, false); this.checkbox = goCheckmark.AddComponent <UnityEngine.UI.Image>(); this.checkbox.sprite = toggleSprite; this.checkbox.type = icoType; if (icoType != UnityEngine.UI.Image.Type.Simple) { this.checkbox. RTQ(). CenterPivot(). ExpandParentFlush(). OffsetMin(togglePad.left, togglePad.bot). OffsetMax(-togglePad.right, -togglePad.top); } else { this.checkbox.RTQ(). CenterPivot(). OffsetMin(0.5f, 0.5f). OffsetMax(0.5f, 0.5f). AnchPos( (togglePad.left - togglePad.right) * 0.5f, (togglePad.bot - togglePad.top) * 0.5f). SizeDelta(toggleSprite.rect.size); } if (textAttrib != null) { GameObject goText = new GameObject("Text_" + name); goText.transform.SetParent(go.transform, false); this.label = goText.AddComponent <UnityEngine.UI.Text>(); this.label.text = text; this.label.horizontalOverflow = HorizontalWrapMode.Overflow; this.label.verticalOverflow = VerticalWrapMode.Overflow; this.label.alignment = TextAnchor.LowerLeft; this.label.RTQ().Pivot(0.0f, 0.0f).BotLeftAnchors(); textAttrib.Apply(this.label); } this.toggle.targetGraphic = this.plate; this.toggle.graphic = this.checkbox; }
public EleHeader(EleBaseRect parent, string text, Font font, Color fontColor, int fontPointSize, Sprite frame, PadRect padding) : base(parent) { this._Create( parent, text, font, fontColor, fontPointSize, frame, padding, new Vector2(-1.0f, -1.0f), ""); }
public EleHeader(EleBaseRect parent, string text, Font font, Color fontColor, int fontPointSize, Sprite frame, PadRect padding, Vector2 size, string name = "") : base(parent, size, name) { this._Create( parent, text, font, fontColor, fontPointSize, frame, padding, size, name); }