void Start() { // setup our text instance which will parse our .fnt file and allow us to var text = new UIText( "prototype", "prototype.png" ); // spawn new text instances showing off the relative positioning features by placing one text instance in each corner var x = UIRelative.xPercentFrom( UIxAnchor.Left, 0f ); var y = UIRelative.yPercentFrom( UIyAnchor.Top, 0f ); text1 = text.addTextInstance( "hello man. I have a line\nbreak", x, y ); var textSize = text.sizeForText( "testing small bitmap fonts", 0.3f ); x = UIRelative.xPercentFrom( UIxAnchor.Left, 0f ); y = UIRelative.yPercentFrom( UIyAnchor.Bottom, 0f, textSize.y ); text2 = text.addTextInstance( "testing small bitmap fonts", x, y, 0.3f ); textSize = text.sizeForText( "with only\n1 draw call\nfor everything", 0.5f ); x = UIRelative.xPercentFrom( UIxAnchor.Right, 0f, textSize.x ); y = UIRelative.yPercentFrom( UIyAnchor.Top, 0f ); text3 = text.addTextInstance( "with only\n1 draw call\nfor everything", x, y, 0.5f, 5, Color.yellow ); textSize = text.sizeForText( "kudos" ); x = UIRelative.xPercentFrom( UIxAnchor.Right, 0f, textSize.x ); y = UIRelative.yPercentFrom( UIyAnchor.Bottom, 0f, textSize.y ); text4 = text.addTextInstance( "kudos", x, y ); textSize = text.sizeForText( "Be sure to try this with\niPhone and iPad resolutions" ); var center = UIRelative.center( textSize.x, textSize.y ); text.addTextInstance( "Be sure to try this with\niPhone and iPad resolutions", center.x, center.y, 1f, 4, Color.red ); StartCoroutine( waitThenRemoveText() ); }
IEnumerator ShowComboScoreTip(int score) { var pos = Vector2.zero; if (LevelHandler.instance.isPlaying) { pos = Crosshair.instance.screenPosition; pos.y = Screen.height - pos.y; } else { pos = new Vector2(Screen.width / 2, Screen.height / 2); } var tipText = "+" + score + " Bonus"; var tipSize = text.sizeForText(tipText); var tip = text.addTextInstance(tipText, pos.x - tipSize.x / 2, pos.y - tipSize.y, 1, 1, Colors.HighlightText); var targetPos = tip.position; targetPos.y += 50; tip.positionTo(1, targetPos, Easing.Linear.easeIn); yield return(new WaitForSeconds(1)); tip.clear(); }
private void updateSize() { Vector2 size = _parentText.sizeForText(_text, _scale); _width = size.x; _height = size.y; this.refreshPosition(); }
void Start() { // setup our text instance which will parse our .fnt file and allow us to var text = new UIText( "prototype", "prototype.png" ); // spawn new text instances showing off the relative positioning features by placing one text instance in each corner var x = UIRelative.xPercentFrom( UIxAnchor.Left, 0f ); var y = UIRelative.yPercentFrom( UIyAnchor.Top, 0f ); text1 = text.addTextInstance( "hello man. I have a line\nbreak", x, y ); var textSize = text.sizeForText( "testing small bitmap fonts", 0.3f ); x = UIRelative.xPercentFrom( UIxAnchor.Left, 0f ); y = UIRelative.yPercentFrom( UIyAnchor.Bottom, 0f, textSize.y ); text2 = text.addTextInstance( "testing small bitmap fonts", x, y, 0.3f ); textSize = text.sizeForText( "with only\n1 draw call\nfor everything", 0.5f ); x = UIRelative.xPercentFrom( UIxAnchor.Right, 0f, textSize.x ); y = UIRelative.yPercentFrom( UIyAnchor.Top, 0f ); text3 = text.addTextInstance( "with only\n1 draw call\nfor everything", x, y, 0.5f, 5, Color.yellow ); textSize = text.sizeForText( "kudos" ); x = UIRelative.xPercentFrom( UIxAnchor.Right, 0f, textSize.x ); y = UIRelative.yPercentFrom( UIyAnchor.Bottom, 0f, textSize.y ); text4 = text.addTextInstance( "kudos", x, y ); textSize = text.sizeForText( "Be sure to try this with\niPhone and iPad resolutions" ); var center = UIRelative.center( textSize.x, textSize.y ); text.addTextInstance( "Be sure to try this with\niPhone and iPad resolutions", center.x, center.y, 1f, 4, Color.red ); x = UIRelative.xPercentFrom( UIxAnchor.Left, 0f ); y = UIRelative.yPercentFrom( UIyAnchor.Bottom, 0f, textSize.y * 3 ); var wrapText = new UIText( "prototype", "prototype.png"); wrapText.wrapMode = UITextLineWrapMode.MinimumLength; wrapText.lineWrapWidth = 200.0f; textWrap1 = wrapText.addTextInstance( "Testing line wrap width with small words in multiple resolutions.", x, y, 0.3f); wrapText.lineWrapWidth = 100.0f; wrapText.wrapMode = UITextLineWrapMode.AlwaysHyphenate; x = UIRelative.xPercentFrom( UIxAnchor.Right, 0f, 200.0f ); y = UIRelative.yPercentFrom( UIyAnchor.Bottom, 0f, textSize.y * 3 ); textWrap2 = wrapText.addTextInstance( "This should be hyphenated.", x, y, 0.5f ); StartCoroutine( waitThenRemoveText() ); }
void Start() { text = UIHelper.getText(); text.alignMode = UITextAlignMode.Right; scoreSize = text.sizeForText("00000", defaultTextScale); DrawScore(); DrawTimer(); DrawPauseButton(); DrawMissileCount(); DrawAlert(); }
void Start() { // setup our text instance which will parse our .fnt file and allow us to var text = new UIText("prototype", "prototype.png"); // spawn new text instances showing off the relative positioning features by placing one text instance in each corner var x = UIRelative.xPercentFrom(UIxAnchor.Left, 0f); var y = UIRelative.yPercentFrom(UIyAnchor.Top, 0f); text1 = text.addTextInstance("hello man. I have a line\nbreak", x, y); var textSize = text.sizeForText("testing small bitmap fonts", 0.3f); x = UIRelative.xPercentFrom(UIxAnchor.Left, 0f); y = UIRelative.yPercentFrom(UIyAnchor.Bottom, 0f, textSize.y); text2 = text.addTextInstance("testing small bitmap fonts", x, y, 0.3f); textSize = text.sizeForText("with only\n1 draw call\nfor everything", 0.5f); x = UIRelative.xPercentFrom(UIxAnchor.Right, 0f, textSize.x); y = UIRelative.yPercentFrom(UIyAnchor.Top, 0f); text3 = text.addTextInstance("with only\n1 draw call\nfor everything", x, y, 0.5f, 5, Color.yellow); textSize = text.sizeForText("kudos"); x = UIRelative.xPercentFrom(UIxAnchor.Right, 0f, textSize.x); y = UIRelative.yPercentFrom(UIyAnchor.Bottom, 0f, textSize.y); text4 = text.addTextInstance("kudos", x, y); textSize = text.sizeForText("Be sure to try this with\niPhone and iPad resolutions"); var center = UIRelative.center(textSize.x, textSize.y); text.addTextInstance("Be sure to try this with\niPhone and iPad resolutions", center.x, center.y, 1f, 4, Color.red); StartCoroutine(waitThenRemoveText()); }
IEnumerator ShowLevel() { // SoundPlayer.PlayFX(levelUp); var color = Colors.HighlightText; if (levelText == null) { var size = text.sizeForText("Level " + difficultLevel); levelText = text.addTextInstance("Level " + difficultLevel, (Screen.width - size.x) / 2, (Screen.height - size.y) / 2); // color.a = 0.8f; levelText.setColorForAllLetters(color); levelText.alignMode = UITextAlignMode.Center; levelText.verticalAlignMode = UITextVerticalAlignMode.Middle; } else { var size = text.sizeForText("Level " + difficultLevel); levelText = text.addTextInstance("Level " + difficultLevel, (Screen.width - size.x) / 2, (Screen.height - size.y) / 2); // color.a = 0.8f; levelText.setColorForAllLetters(color); levelText.alignMode = UITextAlignMode.Center; levelText.verticalAlignMode = UITextVerticalAlignMode.Middle; } levelText.scaleFromTo(0.5f, Vector3.one * 2, Vector3.one * 1.5f, Easing.Quartic.easeOut); // levelText.alphaFromTo(0.5f, 0, 1, Easing.Quartic.easeOut); yield return(new WaitForSeconds(0.5f)); levelText.scaleFromTo(0.5f, Vector3.one * 1.5f, Vector3.one * 3, Easing.Quartic.easeIn); // levelText.alphaFromTo(0.5f, 1, 0, Easing.Linear.easeOut); yield return(new WaitForSeconds(0.5f)); levelText.clear(); }
void Start() { // setup our text instance which will parse our .fnt file and allow us to var text = new UIText( "prototype", "prototype.png" ); // spawn new text instances showing off the relative positioning features by placing one text instance in each corner var x = UIRelative.xPercentFrom( UIxAnchor.Left, 0f ); var y = UIRelative.yPercentFrom( UIyAnchor.Top, 0f ); // Uses default color, scale, alignment, and depth. text.addTextInstance( "hello man. I have a line\nbreak.", x, y ); var textSize = text.sizeForText( "testing small bitmap fonts", 0.3f ); x = UIRelative.xPercentFrom( UIxAnchor.Left, 0f ); y = UIRelative.yPercentFrom( UIyAnchor.Bottom, 0f, textSize.y ); text2 = text.addTextInstance( "testing small bitmap fonts", x, y, 0.3f ); // Centering using alignment modes. x = UIRelative.xPercentFrom( UIxAnchor.Right, 0f ); y = UIRelative.yPercentFrom( UIyAnchor.Top, 0f ); text3 = text.addTextInstance( "with only\n1 draw call\nfor everything", x, y, 0.5f, 5, Color.yellow, UITextAlignMode.Right, UITextVerticalAlignMode.Top ); // High Ascii forcing crash demo. To test this, // Disable "Set Low ASCII Forcing Mode" in the TextManager inspector and see the crash. // Not as handy if you don't need to paste in large amounts of text from word. text.forceLowAscii = setLowAsciiForcingMode; x = UIRelative.xPercentFrom( UIxAnchor.Right, 0, 0 ); y = UIRelative.yPercentFrom( UIyAnchor.Bottom, 0, 0 ); text4 = text.addTextInstance( highAsciiString, x, y, 0.4f, 1, Color.white, UITextAlignMode.Right, UITextVerticalAlignMode.Bottom ); // Centering using text size calculation offset and per-char color var centeredText = "Be sure to try this with\niPhone and iPad resolutions"; var colors = new List<Color>(); for( var i = 0; i < centeredText.Length; i++ ) colors.Add( Color.Lerp( Color.white, Color.magenta, (float)i / centeredText.Length ) ); textSize = text.sizeForText( centeredText ); var center = UIRelative.center( textSize.x, textSize.y ); text.addTextInstance( centeredText, center.x, center.y, 1f, 4, colors.ToArray(), UITextAlignMode.Left, UITextVerticalAlignMode.Top ); // Now center on right side. x = UIRelative.xPercentFrom( UIxAnchor.Right, 0 ); y = UIRelative.yPercentFrom( UIyAnchor.Top, 0.5f ); text.addTextInstance( "Vert-Centering on right side", x, y, 0.5f, 1, Color.white, UITextAlignMode.Right, UITextVerticalAlignMode.Middle ); x = UIRelative.xPercentFrom( UIxAnchor.Left, 0f ); y = UIRelative.yPercentFrom( UIyAnchor.Bottom, 0f, textSize.y * 3 ); var wrapText = new UIText( "prototype", "prototype.png" ); wrapText.wrapMode = UITextLineWrapMode.MinimumLength; wrapText.lineWrapWidth = 100.0f; textWrap1 = wrapText.addTextInstance( "Testing line wrap width with small words in multiple resolutions.\n\nAnd manual L/B.", x, y, 0.3f, 1, Color.white, UITextAlignMode.Left, UITextVerticalAlignMode.Bottom); wrapText.lineWrapWidth = 100.0f; wrapText.wrapMode = UITextLineWrapMode.AlwaysHyphenate; x = UIRelative.xPercentFrom( UIxAnchor.Left, 0.5f ); y = UIRelative.yPercentFrom( UIyAnchor.Bottom, 0f ); textWrap2 = wrapText.addTextInstance( "This should be hyphenated. Check baseline - tytyt", x, y, 0.5f, 1, Color.green, UITextAlignMode.Center, UITextVerticalAlignMode.Bottom ); StartCoroutine( modifyTextInstances() ); }