public virtual void GenerateTextComponent() { textGUI = gameObject.AddComponent <TextMeshProUGUI> (); textGUI.font = GetFont(font); textGUI.enableWordWrapping = enableWordWrapping; textGUI.richText = true; if (fontStyle != null) { textGUI.fontStyle = (FontStyles)Enum.Parse(typeof(FontStyles), fontStyle); } textGUI.fontSize = fontSize; textGUI.overflowMode = overflowMode; //textGUI.extraPadding = true; if (maxVisibleLines > 0) { textGUI.maxVisibleLines = maxVisibleLines; } textGUI.enableAutoSizing = sizeToFit; textGUI.lineSpacing = lineSpacing; textGUI.fontSizeMin = minSize; textGUI.fontSizeMax = maxSize; //public enum TextAlignmentOptions { TopLeft = 0, Top = 1, TopRight = 2, TopJustified = 3, Left = 4, Center = 5, Right = 6, Justified = 7, BottomLeft = 8, Bottom = 9, BottomRight = 10, BottomJustified = 11, BaselineLeft = 12, Baseline = 13, BaselineRight = 14, BaselineJustified = 15 }; textGUI.alignment = alignment; textGUI.color = fontColor; textGUI.text = PlanetUnityStyle.ReplaceStyleTags(value); UpdateRectTransform(); }
public override void gaxb_final(TB.TBXMLElement element, object _parent, Hashtable args) { base.gaxb_final(element, _parent, args); if (element != null) { style = element.GetAttribute("style"); string s = element.GetAttribute("value"); if (s != null) { value = PlanetUnityStyle.ReplaceStyleTags(PlanetUnityOverride.processString(this, s)); } s = element.GetAttribute("autoreload"); if (s != null) { autoreload = bool.Parse(s); } } if (style != null) { string classString = "MarkdownStyle" + style; Type entityClass = Type.GetType(classString, true); mdStyle = (Activator.CreateInstance(entityClass)) as MarkdownStyle; } else { mdStyle = new MarkdownStyleGeneric(); } mdStyle.markdownEntity = this; }
public void GameOver() { if (GameIsOver == false) { GameIsOver = true; Debug.Log("GameIsOver!!!!"); End.gameObject.SetActive(true); EndVignette.CheckCanvasGroup(); EndVignette.canvasGroup.alpha = 0.0f; LeanTween.alpha(EndVignette.gameObject, 1.0f, 0.64f); Vector3 pos = EndLogo.rectTransform.anchoredPosition; EndLogo.rectTransform.anchoredPosition = new Vector3(pos.x, pos.y + 1000, pos.z); LeanTween.moveLocalY(EndLogo.rectTransform, pos.y, 2.0f).setEase(LeanTweenType.easeInOutBounce); EndScoreField.CheckCanvasGroup(); EndScoreField.canvasGroup.alpha = 0.0f; LeanTween.alpha(EndScoreField.gameObject, 1.0f, 0.64f); EndScoreField.text.text = PlanetUnityStyle.ReplaceStyleTags(string.Format("[b3]Score:[/b3] [p3]{0}[/p3]", PlayerScore)); ClickToTryAgain.CheckCanvasGroup(); LeanTween.value(ClickToTryAgain.gameObject, (t, obj) => { ClickToTryAgain.canvasGroup.alpha = t; }, 0.4f, 1.0f, 0.47f).setEase(LeanTweenType.easeOutCubic).setLoopPingPong(); } }
public void AnimateIntro() { BlackCover.CheckCanvasGroup(); BlackCover.canvasGroup.alpha = 1.0f; LeanTween.alpha(BlackCover.gameObject, 0.0f, 0.44f); string levelDesc = string.Format("[b1]Level {0}[/b1]\n[p2]Collect All Turnips\nAvoid Selling Hot Dogs[/p2]", LevelNumber); LevelDesc.text.text = PlanetUnityStyle.ReplaceStyleTags(levelDesc); UpdateScoreField(); }
public override void GenerateTextComponent() { GameObject childObject = new GameObject("TMPro"); childObject.transform.SetParent(rectTransform, false); TextContainer container = childObject.AddComponent <TextContainer> (); container.width = rectTransform.rect.width; container.height = rectTransform.rect.height; container.anchorPosition = TextContainerAnchors.Middle; text = childObject.AddComponent <TextMeshPro> (); text.font = GetFont(font); text.enableWordWrapping = enableWordWrapping; text.richText = true; if (fontStyle != null) { text.fontStyle = (FontStyles)Enum.Parse(typeof(FontStyles), fontStyle); } text.isOverlay = true; text.isOrthographic = true; text.fontSize = fontSize; text.overflowMode = TextOverflowModes.Ellipsis; text.extraPadding = true; if (maxVisibleLines > 0) { textGUI.maxVisibleLines = maxVisibleLines; } text.enableAutoSizing = sizeToFit; text.fontSizeMin = minSize; text.fontSizeMax = maxSize; //public enum TextAlignmentOptions { TopLeft = 0, Top = 1, TopRight = 2, TopJustified = 3, Left = 4, Center = 5, Right = 6, Justified = 7, BottomLeft = 8, Bottom = 9, BottomRight = 10, BottomJustified = 11, BaselineLeft = 12, Baseline = 13, BaselineRight = 14, BaselineJustified = 15 }; text.alignment = alignment; text.color = fontColor; text.text = PlanetUnityStyle.ReplaceStyleTags(value); text.ForceMeshUpdate(); text.fontMaterial.SetFloat(ShaderUtilities.ID_PerspectiveFilter, 0.5f); // You can play with the value to get the result you want. NotificationCenter.addObserver(this, "RemoveAllTMProFast", null, (args, name) => { LeanTween.alpha(gameObject, 0, 0.66f).setEase(LeanTweenType.easeOutCubic).setDestroyOnComplete(true); }); }
public override void gaxb_init() { gameObject = new GameObject("<Text/>", typeof(RectTransform)); canvasRenderer = gameObject.AddComponent <CanvasRenderer> (); text = gameObject.AddComponent <Text> (); if (onLinkClick != null || OnLinkClickAction != null || GlobalOnLinkClickAction != null) { gameObject.AddComponent <DetectTextClick> (); DetectTextClick script = gameObject.GetComponent <DetectTextClick> (); script.entity = this; } if (title == null && value != null) { gameObject.name = string.Format("\"{0}\"", value); } if (fontColor != null) { text.color = fontColor.Value; } if (font != null) { text.font = PlanetUnityResourceCache.GetFont(font); } else { text.font = PlanetUnityResourceCache.GetFont(PlanetUnityOverride.defaultFont()); } if (fontSize != null) { text.fontSize = (int)fontSize; } if (lineSpacing != null) { text.lineSpacing = lineSpacing.Value; } if (sizeToFit) { text.resizeTextForBestFit = true; } if (maxFontSize != null) { text.resizeTextMaxSize = maxFontSize.Value; } if (minFontSize != null) { text.resizeTextMinSize = minFontSize.Value; } if (vOverflow) { text.verticalOverflow = VerticalWrapMode.Overflow; } if (hOverflow) { text.horizontalOverflow = HorizontalWrapMode.Overflow; } if (fontStyle != null) { if (fontStyle == PlanetUnity2.FontStyle.bold) { text.fontStyle = FontStyle.Bold; } if (fontStyle == PlanetUnity2.FontStyle.italic) { text.fontStyle = FontStyle.Italic; } if (fontStyle == PlanetUnity2.FontStyle.normal) { text.fontStyle = FontStyle.Normal; } if (fontStyle == PlanetUnity2.FontStyle.boldAndItalic) { text.fontStyle = FontStyle.BoldAndItalic; } } if (alignment != null) { if (alignment == PlanetUnity2.TextAlignment.lowerCenter) { text.alignment = TextAnchor.LowerCenter; } if (alignment == PlanetUnity2.TextAlignment.lowerLeft) { text.alignment = TextAnchor.LowerLeft; } if (alignment == PlanetUnity2.TextAlignment.lowerRight) { text.alignment = TextAnchor.LowerRight; } if (alignment == PlanetUnity2.TextAlignment.middleCenter) { text.alignment = TextAnchor.MiddleCenter; } if (alignment == PlanetUnity2.TextAlignment.middleLeft) { text.alignment = TextAnchor.MiddleLeft; } if (alignment == PlanetUnity2.TextAlignment.middleRight) { text.alignment = TextAnchor.MiddleRight; } if (alignment == PlanetUnity2.TextAlignment.upperCenter) { text.alignment = TextAnchor.UpperCenter; } if (alignment == PlanetUnity2.TextAlignment.upperLeft) { text.alignment = TextAnchor.UpperLeft; } if (alignment == PlanetUnity2.TextAlignment.upperRight) { text.alignment = TextAnchor.UpperRight; } } if (value != null) { text.text = PlanetUnityStyle.ReplaceStyleTags(value); } text.material = new Material(Shader.Find("UI/Default Font")); }
public void UpdateScoreField() { PlayerScoreField.text.text = PlanetUnityStyle.ReplaceStyleTags(string.Format("[b3]Score:[/b3] [p3]{0}[/p3]", PlayerScore)); TurnipScore.text.text = string.Format("{0} of {1}", NumberOfCollectedTurnips, NumberOfTurnipsThisLevel); }