static private float AnimateTextMoveIn(DialogType type, PUText text, float delay) { float duration = AnimateTextDuration(type, text.text.text); if (type == DialogType.Response) { // animate in from the right text.rectTransform.anchoredPosition = new Vector2(text.rectTransform.rect.width, 0); LeanTween.value(text.gameObject, (v) => { text.rectTransform.anchoredPosition = new Vector2(v, 0); }, text.rectTransform.rect.width, 0, duration).setEase(LeanTweenType.easeOutCubic).setDelay(delay); } else if (type == DialogType.Character) { // animate in from the bottom text.rectTransform.anchoredPosition = new Vector2(0, -text.rectTransform.rect.height); LeanTween.value(text.gameObject, (v) => { text.rectTransform.anchoredPosition = new Vector2(0, -v); }, text.rectTransform.rect.height, 0, duration).setEase(LeanTweenType.easeOutCubic).setDelay(delay); } return(duration + delay); }
static private float AnimateTextTyping(DialogType type, PUText text, float delay) { string content = text.text.text; text.text.text = ""; LeanTween.value(text.gameObject, (v) => { text.text.text = content.Substring(0, Mathf.RoundToInt(v)); }, 0, content.Length, AnimateTextDuration(type, content)).setEase(LeanTweenType.linear).setDelay(delay); return(AnimateTextDuration(type, content) + delay); }
static public float AnimateText(DialogType type, PUText text, float delay) { if (type == DialogType.Character) { return(AnimateTextTyping(type, text, delay)); } else if (type == DialogType.Response) { return(AnimateTextMoveIn(type, text, delay)); } return(AnimateTextMoveIn(type, text, delay)); }
public void LinkClicked(string linkText, int linkID) { if (TranslateLinkAction != null) { linkText = TranslateLinkAction(linkText, linkID); } if (OnLinkClickAction != null) { OnLinkClickAction(linkText, linkID); } if (OnLinkClickAction == null && PUText.GlobalOnLinkClickAction != null) { PUText.GlobalOnLinkClickAction(linkText, linkID, this); } if (onLinkClick != null) { NotificationCenter.postNotification(Scope(), onLinkClick, NotificationCenter.Args("link", linkText, "linkID", linkID)); } }
public override void gaxb_init() { // We call Text's gaxb_init, which creates the appropriate text component on gameObject base.gaxb_init(); textGameObject = gameObject; // Next, we create a new gameObject, and put the Text-created gameObject inside me gameObject = new GameObject("<InputField/>", typeof(RectTransform)); canvasRenderer = gameObject.AddComponent <CanvasRenderer> (); field = gameObject.AddComponent <InputField> (); // Move the text to be the child of the input field textGameObject.transform.SetParent(gameObject.transform, false); textGameObject.FillParentUI(); text.supportRichText = false; text.alignment = TextAnchor.UpperLeft; field.transition = Selectable.Transition.None; field.textComponent = text; if (contentType == PlanetUnity2.InputFieldContentType.standard) { field.contentType = InputField.ContentType.Standard; } else if (contentType == PlanetUnity2.InputFieldContentType.autocorrected) { field.contentType = InputField.ContentType.Autocorrected; } else if (contentType == PlanetUnity2.InputFieldContentType.integer) { field.contentType = InputField.ContentType.IntegerNumber; } else if (contentType == PlanetUnity2.InputFieldContentType.number) { field.contentType = InputField.ContentType.DecimalNumber; } else if (contentType == PlanetUnity2.InputFieldContentType.alphanumeric) { field.contentType = InputField.ContentType.Alphanumeric; } else if (contentType == PlanetUnity2.InputFieldContentType.name) { field.contentType = InputField.ContentType.Name; } else if (contentType == PlanetUnity2.InputFieldContentType.email) { field.contentType = InputField.ContentType.EmailAddress; } else if (contentType == PlanetUnity2.InputFieldContentType.password) { field.contentType = InputField.ContentType.Password; } else if (contentType == PlanetUnity2.InputFieldContentType.pin) { field.contentType = InputField.ContentType.Pin; } else if (contentType == PlanetUnity2.InputFieldContentType.custom) { field.contentType = InputField.ContentType.Custom; field.onValidateInput += ValidateInput; } if (lineType == PlanetUnity2.InputFieldLineType.single) { field.lineType = InputField.LineType.SingleLine; } else if (lineType == PlanetUnity2.InputFieldLineType.multiSubmit) { field.lineType = InputField.LineType.MultiLineSubmit; } else if (lineType == PlanetUnity2.InputFieldLineType.multiNewline) { field.lineType = InputField.LineType.MultiLineNewline; } if (placeholder != null) { placeholderText = new PUText(); placeholderText.value = this.placeholder; placeholderText.LoadIntoPUGameObject(this); placeholderText.text.horizontalOverflow = this.text.horizontalOverflow; placeholderText.text.verticalOverflow = this.text.verticalOverflow; placeholderText.text.alignment = this.text.alignment; placeholderText.text.font = this.text.font; placeholderText.text.fontSize = this.text.fontSize; placeholderText.text.fontStyle = this.text.fontStyle; placeholderText.text.color = this.text.color - new Color(0, 0, 0, 0.5f); placeholderText.text.lineSpacing = this.text.lineSpacing; placeholderText.gameObject.FillParentUI(); field.placeholder = placeholderText.text; } if (limit != null) { field.characterLimit = (int)limit; } if (selectionColor != null) { field.selectionColor = selectionColor.Value; } // This is probably not the best way to do this, but 4.60.f1 removed the onSubmit event field.onEndEdit.AddListener((value) => { if (onValueChanged != null) { NotificationCenter.postNotification(Scope(), this.onValueChanged, NotificationCenter.Args("sender", this)); } }); foreach (Object obj in gameObject.GetComponentsInChildren <DetectTextClick>()) { GameObject.Destroy(obj); } field.Rebuild(CanvasUpdate.LatePreRender); if (this.value == null) { this.value = ""; } field.text = this.value; }
public override void gaxb_init() { // We call Text's gaxb_init, which creates the appropriate text component on gameObject base.gaxb_init (); textGameObject = gameObject; // Next, we create a new gameObject, and put the Text-created gameObject inside me gameObject = new GameObject ("<InputField/>", typeof(RectTransform)); canvasRenderer = gameObject.AddComponent<CanvasRenderer> (); field = gameObject.AddComponent<InputField> (); // Move the text to be the child of the input field textGameObject.transform.SetParent (gameObject.transform, false); textGameObject.FillParentUI (); text.supportRichText = false; text.alignment = TextAnchor.UpperLeft; field.transition = Selectable.Transition.None; field.textComponent = text; if (contentType == PlanetUnity2.InputFieldContentType.standard) { field.contentType = InputField.ContentType.Standard; } else if (contentType == PlanetUnity2.InputFieldContentType.autocorrected) { field.contentType = InputField.ContentType.Autocorrected; } else if (contentType == PlanetUnity2.InputFieldContentType.integer) { field.contentType = InputField.ContentType.IntegerNumber; } else if (contentType == PlanetUnity2.InputFieldContentType.number) { field.contentType = InputField.ContentType.DecimalNumber; } else if (contentType == PlanetUnity2.InputFieldContentType.alphanumeric) { field.contentType = InputField.ContentType.Alphanumeric; } else if (contentType == PlanetUnity2.InputFieldContentType.name) { field.contentType = InputField.ContentType.Name; } else if (contentType == PlanetUnity2.InputFieldContentType.email) { field.contentType = InputField.ContentType.EmailAddress; } else if (contentType == PlanetUnity2.InputFieldContentType.password) { field.contentType = InputField.ContentType.Password; } else if (contentType == PlanetUnity2.InputFieldContentType.pin) { field.contentType = InputField.ContentType.Pin; } else if (contentType == PlanetUnity2.InputFieldContentType.custom) { field.contentType = InputField.ContentType.Custom; field.onValidateInput += ValidateInput; } if (lineType == PlanetUnity2.InputFieldLineType.single) { field.lineType = InputField.LineType.SingleLine; } else if (lineType == PlanetUnity2.InputFieldLineType.multiSubmit) { field.lineType = InputField.LineType.MultiLineSubmit; } else if (lineType == PlanetUnity2.InputFieldLineType.multiNewline) { field.lineType = InputField.LineType.MultiLineNewline; } if (placeholder != null) { placeholderText = new PUText (); placeholderText.value = this.placeholder; placeholderText.LoadIntoPUGameObject (this); placeholderText.text.horizontalOverflow = this.text.horizontalOverflow; placeholderText.text.verticalOverflow = this.text.verticalOverflow; placeholderText.text.alignment = this.text.alignment; placeholderText.text.font = this.text.font; placeholderText.text.fontSize = this.text.fontSize; placeholderText.text.fontStyle = this.text.fontStyle; placeholderText.text.color = this.text.color - new Color(0,0,0,0.5f); placeholderText.text.lineSpacing = this.text.lineSpacing; placeholderText.gameObject.FillParentUI (); field.placeholder = placeholderText.text; } if (limit != null) { field.characterLimit = (int)limit; } if (selectionColor != null) { field.selectionColor = selectionColor.Value; } // This is probably not the best way to do this, but 4.60.f1 removed the onSubmit event field.onEndEdit.AddListener ((value) => { if(onValueChanged != null){ NotificationCenter.postNotification (Scope (), this.onValueChanged, NotificationCenter.Args("sender", this)); } }); foreach (Object obj in gameObject.GetComponentsInChildren<DetectTextClick>()) { GameObject.Destroy (obj); } field.Rebuild (CanvasUpdate.LatePreRender); }