public override void UpdateContents() { StoryEngine.Dialog data = cellData as StoryEngine.Dialog; responseText = new PUTextButton(); responseText.font = "Fonts/PressStart2P"; responseText.value = data.text; responseText.fontSize = 22; if (data.isHelpHeader) { responseText.fontSize = 14; } responseText.lineSpacing = 1.4f; responseText.fontColor = Color.white; responseText.alignment = PlanetUnity2.TextAlignment.upperLeft; responseText.SetFrame(0, 0, 378, 100, 0.5f, 0.5f, "stretch,stretch"); responseText.LoadIntoPUGameObject(puGameObject); responseText.SetStretchStretch(30, 0, 30, 0); TextGenerator textGen = new TextGenerator(); TextGenerationSettings generationSettings = responseText.text.GetGenerationSettings(responseText.rectTransform.rect.size); float height = textGen.GetPreferredHeight(data.text, generationSettings) + 60; puGameObject.rectTransform.sizeDelta = new Vector2(responseText.rectTransform.rect.width, height); if (data.isHelpHeader) { responseText.text.color = Color.yellow; LeanTween.value(responseText.gameObject, (v) => { responseText.rectTransform.localScale = new Vector3(v, v, 1.0f); }, 0.98f, 1.02f, 2.0f).setLoopCount(-1).setLoopPingPong().setEase(LeanTweenType.easeInOutCirc); } else { responseText.button.onClick.AddListener(() => { NotificationCenter.postNotification(null, "NavigateToRoom", NotificationCenter.Args("room", data.room)); }); } AnimateText(DialogType.Response, responseText, data.animationDelay); /* * responseText.rectTransform.anchoredPosition = new Vector2(responseText.rectTransform.rect.width, 0); * LeanTween.value (puGameObject.gameObject, (v) => { * responseText.rectTransform.anchoredPosition = new Vector2(v, 0); * }, responseText.rectTransform.rect.width, 0, 0.47f).setDelay (UnityEngine.Random.Range (0.67f, 1.32f)).setEase (LeanTweenType.easeInOutQuad); */ }
public override void gaxb_complete() { base.gaxb_complete(); MinimalVideoTextureGraphic mvt = gameObject.AddComponent <MinimalVideoTextureGraphic>(); mvt.loops = loops; mvt.resourcePath = resourcePath; if (onFinished != null) { mvt.MovieDidFinishBlock = () => { NotificationCenter.postNotification(Scope(), this.onFinished, NotificationCenter.Args("sender", this)); }; } }
public void OnPointerDown(PointerEventData data) { NotificationCenter.postNotification(null, PlanetUnity2.BUTTONTOUCHDOWN, NotificationCenter.Args("sender", scopeObj)); if (note != null) { if (scopeObj != null && scopeObj is PUGameObject) { NotificationCenter.postNotification((scopeObj as PUGameObject).Scope(), note, NotificationCenter.Args("sender", scopeObj)); } else { NotificationCenter.postNotification(null, note); } } }
public static void SetOnTouchUp(PUGameObject gmObj, Button btn, string newNote) { if (btn != null && newNote != null) { btn.onClick.RemoveAllListeners(); btn.onClick.AddListener(() => { if (gmObj != null) { NotificationCenter.postNotification(gmObj.Scope(), newNote, NotificationCenter.Args("sender", gmObj)); } else { NotificationCenter.postNotification(null, newNote); } }); } }
public void LinkClicked(string linkText, int linkID) { if (TranslateLinkAction != null) { linkText = TranslateLinkAction(linkText, linkID); } if (OnLinkClickAction != null) { OnLinkClickAction(linkText, linkID); } if (OnLinkClickAction == null && GlobalOnLinkClickAction != null) { GlobalOnLinkClickAction(linkText, linkID, this); } if (onLinkClick != null) { NotificationCenter.postNotification(Scope(), onLinkClick, NotificationCenter.Args("link", linkText)); } }
public static void SetOnTouchUp(PUGameObject gmObj, Button btn, string newNote) { if (btn != null) { btn.onClick.RemoveAllListeners(); btn.onClick.AddListener(() => { NotificationCenter.postNotification(null, PlanetUnity2.BUTTONTOUCHUP, NotificationCenter.Args("sender", gmObj)); HandleGlobalButtonOnTouchUp(gmObj); if (newNote != null) { if (gmObj != null) { NotificationCenter.postNotification(gmObj.Scope(), newNote, NotificationCenter.Args("sender", gmObj)); } else { NotificationCenter.postNotification(null, newNote); } } }); } }
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromPath) { foreach (string asset in importedAssets) { NotificationCenter.postNotification(null, PlanetUnity2.EDITORFILEDIDCHANGE, NotificationCenter.Args("path", asset)); } if (Application.isPlaying == false) { GameObject puObject = GameObject.Find("PlanetUnity"); if (puObject == null) { return; } PlanetUnityGameObject script = puObject.GetComponent <PlanetUnityGameObject> (); if (script == null) { return; } script.EditorReloadCanvas(); } }
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 void OnPointerDown(PointerEventData data) { if (scopeObj != null && scopeObj is PUGameObject) { NotificationCenter.postNotification((scopeObj as PUGameObject).Scope(), note, NotificationCenter.Args("sender", scopeObj)); } else { NotificationCenter.postNotification(null, note); } }
public override void gaxb_init() { base.gaxb_init(); if (title == null) { gameObject.name = "<Slider/>"; } slider = gameObject.AddComponent <Slider> (); if (fillResourcePath != null) { fill = new PUImage(fillResourcePath, Color.white); fill.SetFrame(0, 0, 0, 0, 0.5f, 0.5f, "stretch,stretch"); fill.LoadIntoPUGameObject(this); } handle = new PUImage(handleResourcePath, Color.white); handle.SetFrame(0, 0, handleSize.Value.x, handleSize.Value.y, 0.5f, 0.5f, "stretch,stretch"); if (handleResourcePath == null) { handle.color = Color.clear; } handle.LoadIntoPUGameObject(this); if (onValueChanged != null) { slider.onValueChanged.AddListener((v) => { NotificationCenter.postNotification(Scope(), this.onValueChanged, NotificationCenter.Args("sender", this, "value", v)); }); } slider.targetGraphic = handle.image; slider.handleRect = handle.rectTransform; if (fill != null) { slider.fillRect = fill.rectTransform; } if (direction == PlanetUnity2.SliderDirection.BottomToTop) { slider.direction = Slider.Direction.BottomToTop; } else if (direction == PlanetUnity2.SliderDirection.TopToBottom) { slider.direction = Slider.Direction.TopToBottom; } else if (direction == PlanetUnity2.SliderDirection.LeftToRight) { slider.direction = Slider.Direction.LeftToRight; } else if (direction == PlanetUnity2.SliderDirection.RightToLeft) { slider.direction = Slider.Direction.RightToLeft; } if (minValue != null) { slider.minValue = (float)minValue; } if (maxValue != null) { slider.maxValue = (float)maxValue; } handle.rectTransform.sizeDelta = new Vector2(handleSize.Value.x, handleSize.Value.y); }
public override void gaxb_complete() { base.gaxb_complete(); // At this point, our gameObject is our "text" game object. We want to maneuver things around // until its like: // --> TMPro - Input Field // --> Text Area // --> Placeholder // --> Text // 0) first, swap out our TMPro text and replace our gameObject with one with the text field GameObject textGameObject = gameObject; // Next, we create a new gameObject, and put the Text-created gameObject inside me gameObject = new GameObject("<TMP_InputField/>", typeof(RectTransform)); gameObject.transform.SetParent(textGameObject.transform.parent, false); UpdateRectTransform(); // 0.5) Create a game object for the field inputField = new PUGameObject(); inputField.title = "TMP_InputField"; inputField.SetFrame(0, 0, 0, 0, 0, 0, "stretch,stretch"); inputField.LoadIntoPUGameObject(this); // 1) create the hierarchy of stuff under me textArea = new PUGameObject(); textArea.title = "Text Area"; textArea.SetFrame(0, 0, 0, 0, 0, 0, "stretch,stretch"); textArea.LoadIntoPUGameObject(inputField); // 2) placeholder if (placeholder != null) { placeholderText = new PUTMPro(); placeholderText.title = "Placeholder"; placeholderText.value = this.placeholder; placeholderText.LoadIntoPUGameObject(textArea); placeholderText.textGUI.overflowMode = this.textGUI.overflowMode; placeholderText.textGUI.alignment = this.textGUI.alignment; placeholderText.textGUI.font = this.textGUI.font; placeholderText.textGUI.fontSize = this.textGUI.fontSize; placeholderText.textGUI.fontStyle = this.textGUI.fontStyle; placeholderText.textGUI.color = this.textGUI.color - new Color(0, 0, 0, 0.5f); placeholderText.textGUI.lineSpacing = this.textGUI.lineSpacing; placeholderText.gameObject.FillParentUI(); } // 3) text text = new PUGameObject(); text.SetFrame(0, 0, 0, 0, 0, 0, "stretch,stretch"); text.LoadIntoPUGameObject(textArea); GameObject.Destroy(text.gameObject); text.gameObject = textGameObject; // Move the text to be the child of the input field textGameObject.name = "Text"; textGameObject.transform.SetParent(textArea.rectTransform, false); textGameObject.FillParentUI(); (textGameObject.transform as RectTransform).pivot = Vector2.zero; // now that we have the hierarchy, fille out the input field field = inputField.gameObject.AddComponent <TMP_InputField> (); field.transition = Selectable.Transition.None; field.targetGraphic = inputField.gameObject.AddComponent <InvisibleHitGraphic> (); field.textViewport = textArea.rectTransform; field.textComponent = textGUI; if (asteriskChar != null) { field.asteriskChar = asteriskChar.Value; } if (contentType == PlanetUnity2.InputFieldContentType.standard) { field.contentType = TMP_InputField.ContentType.Standard; } else if (contentType == PlanetUnity2.InputFieldContentType.autocorrected) { field.contentType = TMP_InputField.ContentType.Autocorrected; } else if (contentType == PlanetUnity2.InputFieldContentType.integer) { field.contentType = TMP_InputField.ContentType.IntegerNumber; } else if (contentType == PlanetUnity2.InputFieldContentType.number) { field.contentType = TMP_InputField.ContentType.DecimalNumber; } else if (contentType == PlanetUnity2.InputFieldContentType.alphanumeric) { field.contentType = TMP_InputField.ContentType.Alphanumeric; } else if (contentType == PlanetUnity2.InputFieldContentType.name) { field.contentType = TMP_InputField.ContentType.Name; } else if (contentType == PlanetUnity2.InputFieldContentType.email) { field.contentType = TMP_InputField.ContentType.EmailAddress; } else if (contentType == PlanetUnity2.InputFieldContentType.password) { field.contentType = TMP_InputField.ContentType.Password; field.inputType = TMP_InputField.InputType.Password; } else if (contentType == PlanetUnity2.InputFieldContentType.pin) { field.contentType = TMP_InputField.ContentType.Pin; } else if (contentType == PlanetUnity2.InputFieldContentType.custom) { field.contentType = TMP_InputField.ContentType.Custom; field.onValidateInput += ValidateInput; } if (lineType == PlanetUnity2.InputFieldLineType.single) { field.lineType = TMP_InputField.LineType.SingleLine; } else if (lineType == PlanetUnity2.InputFieldLineType.multiSubmit) { field.lineType = TMP_InputField.LineType.MultiLineSubmit; } else if (lineType == PlanetUnity2.InputFieldLineType.multiNewline) { field.lineType = TMP_InputField.LineType.MultiLineNewline; } if (characterLimit != null) { field.characterLimit = (int)characterLimit; } 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 <DetectTextClickTMPro>()) { GameObject.Destroy(obj); } if (this.value == null) { this.value = ""; } field.text = this.value; if (placeholder != null) { field.placeholder = placeholderText.textGUI; } }