/// <summary> /// resets the start value to the current. useful for when the sprite has moved/scaled/changed and you still want to use the same UIAnimation /// </summary> public void restartStartToCurrent() { switch (_aniProperty) { case UIAnimationProperty.Position: start = sprite.localPosition; break; case UIAnimationProperty.Scale: start = sprite.scale; break; case UIAnimationProperty.EulerAngles: start = sprite.eulerAngles; break; case UIAnimationProperty.Alpha: Color currentColor = sprite.color; startFloat = currentColor.a; break; case UIAnimationProperty.Color: startColor = sprite.color; break; case UIAnimationProperty.TextScale: UITextInstance txt = (UITextInstance)sprite; startFloat = txt.textScale; break; } }
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() ); }
public static void textPositionInWrapper(UITextInstance text) { int textOffset = 4; hd(ref textOffset); text.pixelsFromTopLeft(textOffset, textOffset); }
protected void recurseAndClipChildren(UIObject child) { foreach (Transform t in child.client.transform) { UIElement uie = t.GetComponent <UIElement>(); if (uie != null) { UIObject o = t.GetComponent <UIElement>().UIObject; if (o != null) { UISprite s = o as UISprite; if (s != null) { clipChild(s); } else { UITextInstance ti = o as UITextInstance; if (ti != null) { // Special handeling for text foreach (UISprite glyph in ti.textSprites) { clipChild(glyph); } } recurseAndClipChildren(ti); } } } } }
// HACK: Gabo /// <summary> /// Gabo Edit /// Removes all the children from the container and from it's manager. /// </summary> public virtual void removeAllChildren() { for (int i = _uiTextChildren.Count - 1; i >= 0; i--) { UITextInstance child = _uiTextChildren[i]; _uiTextChildren.Remove(child); child.parentUIObject = null; //child.clear(); child.destroy(); //Debug.Log("Clearing Text"); } for (int i = _uiChildren.Count - 1; i >= 0; i--) { UISprite child = _uiChildren[i]; _uiChildren.Remove(child); child.parentUIObject = null; child.manager.removeElement(child); } for (int i = _children.Count - 1; i >= 0; i--) { UISprite child = _children[i]; _children.Remove(child); child.parentUIObject = null; child.manager.removeElement(child); } }
private void createStartScreen() { int buttonsBottomOffset = 130; // Single Player Button UIButton singlePlayerButton = UIButton.create(uiTools, "dieButtonLarge.png", "dieButtonLargeDown.png", 0, 0, 10); singlePlayerButton.pixelsFromBottomLeft(buttonsBottomOffset, 13); UITextInstance singlePlayerText = graph20.addTextInstance("Single\nPlayer", 0, 0); singlePlayerText.parentUIObject = singlePlayerButton; singlePlayerText.pixelsFromTopRight(45, 24); // Multi Player Button UIButton multiPlayerButton = UIButton.create(uiTools, "dieButtonLarge.png", "dieButtonLargeDown.png", 0, 0, 10); multiPlayerButton.pixelsFromBottomRight(buttonsBottomOffset, 50); UITextInstance multiPlayerText = graph20.addTextInstance("Multi\nPlayer", 0, 0); multiPlayerText.parentUIObject = multiPlayerButton; multiPlayerText.pixelsFromTopRight(45, 24); // How To Play Button UIButton howToPlayButton = UIButton.create(uiTools, "howToPlayButton.png", "howToPlayButton.png", 0, 0, 10); howToPlayButton.pixelsFromBottomLeft(0, 5); // Stats Button UIButton statsButton = UIButton.create(uiTools, "statsButton.png", "statsButton.png", 0, 0, 10); statsButton.pixelsFromBottomRight(-10, 0); // Current Games UISprite currentGamesBG = uiTools.addSprite("currentGamesBG.png", 0, 0, 15); currentGamesBG.pixelsFromTop(45); // Current Games Scroller currentGamesLayout = new UIScrollableHorizontalLayout(10); currentGamesLayout.setSize(Screen.width, GUIUtils.hdReturn(90)); currentGamesLayout.parentUIObject = currentGamesBG; currentGamesLayout.pixelsFromBottom(8); // TODO: Add temp games findCurrentGames(); // Parent everything to the startScreenParent UIObject[] objects = { singlePlayerButton, singlePlayerText, multiPlayerButton, multiPlayerText, howToPlayButton, statsButton, currentGamesBG, currentGamesLayout }; foreach (UIObject item in objects) { item.parentUIObject = startScreenParent; } // Move the panel off screen startScreenParent.positionFromTopLeft(0, 1); }
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 // Uses default color, scale, alignment, and depth. text1 = text.addTextInstance( "hello man. I have a line\nbreak.", 0, 0 ); text1.pixelsFromTopLeft( 0, 0 ); text2 = text.addTextInstance( "testing small bitmap fonts", 0, 0, 0.3f ); text2.pixelsFromBottomLeft( 25, 0 ); // Centering using alignment modes. text3 = text.addTextInstance( "with only\n1 draw call\nfor everything", 0, 0, 0.5f, 5, Color.yellow, UITextAlignMode.Right, UITextVerticalAlignMode.Top ); text3.positionFromTopLeft( 0.5f, 0.2f ); // 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; text4 = text.addTextInstance( highAsciiString, 0, 0, 0.4f, 1, Color.white, UITextAlignMode.Right, UITextVerticalAlignMode.Bottom ); text4.positionFromBottomRight( 0f, 0f ); // 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 ) ); text5 = text.addTextInstance( centeredText, 0, 0, 1f, 4, colors.ToArray(), UITextAlignMode.Left, UITextVerticalAlignMode.Middle ); text5.positionFromLeft( -0.1f, 0f ); // Now center on right side. text6 = text.addTextInstance( "Vert-Centering on right side", 0, 0, 0.5f, 1, Color.white, UITextAlignMode.Right, UITextVerticalAlignMode.Middle ); text6.positionFromTopRight( 0.3f, 0f ); 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.", 0, 0, 0.3f, 1, Color.white, UITextAlignMode.Left, UITextVerticalAlignMode.Bottom ); textWrap1.positionFromBottomLeft( 0.1f, 0.1f ); wrapText.lineWrapWidth = 100.0f; wrapText.wrapMode = UITextLineWrapMode.AlwaysHyphenate; textWrap2 = wrapText.addTextInstance( "This should be hyphenated. Check baseline - tytyt", 0, 0, 0.5f, 1, Color.green, UITextAlignMode.Center, UITextVerticalAlignMode.Bottom ); textWrap2.positionFromBottom( 0f ); StartCoroutine( modifyTextInstances() ); }
// Use this for initialization void Start() { UIText fnt = new UIText("Pourquoi64", "Pourquoi64.png"); text = fnt.addTextInstance("The quick brown fox", 20, 20); text.setColorForAllLetters(Color.yellow); text2 = fnt.addTextInstance("jumps over the lazy dog", 20, 60, 0.75f); text2.setColorForAllLetters(Color.red); }
public UITextInstance addTextInstance(string text, float xPos, float yPos, float scale, int depth, Color color) { var textInstance = new UITextInstance(this, text, xPos, yPos, scale, depth, color); textInstance.textIndex = drawText(text, xPos, yPos, scale, depth, color); return(textInstance); }
public void Start() { timeText = new UIText(textButtonManager, "VogueCyrBold_60_ffffff", "VogueCyrBold_60_ffffff.png"); timetext1 = timeText.addTextInstance(string.Format("{0} : 30", minutes), 0, 0); timetext1.color = Color.black; timetext1.positionFromCenter(-0.38f, 0f); InvokeRepeating("countDown", 1, 1); }
void Start() { timeleft = updateInterval; var text = UIHelper.getText(); fpsText = text.addTextInstance("FPS", 135, 16); fpsText.setColorForAllLetters(Colors.HighlightText); }
void createStatsPanel() { finalScoreBox = UI.firstToolkit.addSprite("finalScoreBox.png", 0, 0); finalScoreBox.positionCenter(); string finalScore = "score: " + gameManager.scorePoints.ToString(); finalScoreText = textManager.addTextInstance(finalScore, 0.0f, 0.0f, 1.5f); finalScoreText.parentUIObject = finalScoreBox; finalScoreText.positionFromTopLeft(0.02f, 0.02f); string totalESCatched = "total ES catched: " + gameManager.totalESCatched.ToString(); totalESCatchedText = textManager.addTextInstance(totalESCatched, 0.0f, 0.0f, 1.0f); totalESCatchedText.parentUIObject = finalScoreText; totalESCatchedText.positionFromTopLeft(1.01f, 0.0f); string totalESMissed = "total ES missed: " + gameManager.totalESMissed.ToString(); totalESMissedText = textManager.addTextInstance(totalESMissed, 0.0f, 0.0f, 1.0f); totalESMissedText.parentUIObject = totalESCatchedText; totalESMissedText.positionFromTopLeft(1.01f, 0.0f); string totalESSpawned = "total ES spawned: " + gameManager.totalESSpawned.ToString(); totalESSpawnedText = textManager.addTextInstance(totalESSpawned, 0.0f, 0.0f, 1.0f); totalESSpawnedText.parentUIObject = totalESMissedText; totalESSpawnedText.positionFromTopLeft(1.01f, 0.0f); string totalGameTime = "game time: " + gameManager.totalGameTime.ToString(); totalGameTimeText = textManager.addTextInstance(totalGameTime, 0.0f, 0.0f, 1.0f); totalGameTimeText.parentUIObject = totalESSpawnedText; totalGameTimeText.positionFromTopLeft(1.01f, 0.0f); string totalCombo = "combos number: " + gameManager.totalCombo.ToString(); totalComboText = textManager.addTextInstance(totalCombo, 0.0f, 0.0f, 1.0f); totalComboText.parentUIObject = totalGameTimeText; totalComboText.positionFromTopLeft(1.01f, 0.0f); string totalEvolutions = "evolution level: " + gameManager.totalEvolutions.ToString(); totalEvolutionsText = textManager.addTextInstance(totalEvolutions, 0.0f, 0.0f, 1.0f); totalEvolutionsText.parentUIObject = totalComboText; totalEvolutionsText.positionFromTopLeft(1.01f, 0.0f); leaderboardButton = UIButton.create("leaderboard.png", "leaderboard.png", 0, 0); leaderboardButton.onTouchUp += onTouchLeaderboardButton;; leaderboardButton.parentUIObject = finalScoreBox; leaderboardButton.positionFromBottomRight(0.01f, 0.01f); homeButton = UIButton.create("home.png", "home.png", 0, 0); homeButton.onTouchUp += onTouchHomeButton; homeButton.parentUIObject = finalScoreBox; homeButton.positionFromBottomLeft(0.01f, 0.01f); }
void createSplashScreen() { splashScreenButton = UIButton.create("splash.png", "splash.png", 0, 0); splashScreenButton.onTouchUp += onTouchSplashScreen; splashScreenButton.positionCenter(); splashText = textManager.addTextInstance("Tap to continue...", 0, 0); splashText.positionFromBottom(0.1f); }
void Start() { toolkitText = toolkitAssets.getLabelText(); labelTimer = toolkitText.addTextInstance("0:00.0", 0, 0, 1f, 15); labelTimer.positionFromTopLeft(0.03f, 0.5f); //remove this if you will send restart level message // onRestartLevel(); }
public void updateColorForTextInstance(ref UITextInstance textInstance) { // how many sprites are we updated? int length = _textSprites[textInstance.textIndex].Length; for (int i = 0; i < length; i++) { _textSprites[textInstance.textIndex][i].color = textInstance.color; } }
void DrawScore() { var x = Screen.width / 2 - 10; scoreButton = spriteManager.addSprite("button_score.png", x, 0); scoreXPos = x + 62; scoreText = text.addTextInstance(LevelHandler.instance.score.ToString(), scoreXPos, scoreYPos, defaultTextScale, 1, Colors.HighlightText); scoreText.autoRefreshPositionOnScaling = false; }
// Use this for initialization void Start() { uiToolkit = GetComponent <UIToolkit>(); fnt = new UIText(uiToolkit, fontName, fontName + ".png"); text = fnt.addTextInstance("", 0, 0, fontScale, 3); text.alignMode = UITextAlignMode.Center; text.verticalAlignMode = UITextVerticalAlignMode.Bottom; Hide(); }
public UITextInstance addTextInstance( string text, float xPos, float yPos, float scale, int depth, Color[] colors, UITextAlignMode alignMode, UITextVerticalAlignMode verticalAlignMode ) { if( forceLowAscii ) forceLowAsciiString( ref text ); var textInstance = new UITextInstance( this, text, xPos, yPos, scale, depth, colors, alignMode, verticalAlignMode ); textInstance.parent = _manager.transform; drawText(textInstance, textInstance.xPos, textInstance.yPos, textInstance.textScale, textInstance.depth, colors, textInstance.alignMode, textInstance.verticalAlignMode); return textInstance; }
void Start() { //Initialize Score scoreText = new UIText(textButtonManager, "VogueCyrBold_60_ffffff", "VogueCyrBold_60_ffffff.png"); scoretext1 = scoreText.addTextInstance(string.Format("{0}", score), 0, 0); scoretext1.color = Color.black; scoretext2 = scoreText.addTextInstance(string.Format("{0}", TargetScore), 0, 0); scoretext2.color = Color.black; scoretext1.positionFromTopLeft(0.1f, 0.18f); //display for score scoretext2.positionFromTopLeft(0.1f, 0.78f); }
void Start() { toolkitText = toolkitAssets.getLabelText(); label = toolkitText.addTextInstance(initialText, 0, 0, fontScale, 15); label.positionFromTopLeft(posFromTop, posFromLeft); if (initiallyHidden) { label.hidden = true; } }
void DrawTimer() { var x = Screen.width / 2 - 180; timerButton = spriteManager.addSprite("button_time.png", x, 0); x += 62; timerText = text.addTextInstance(LevelHandler.instance.formattedTimer, x, scoreYPos); timerText.textScale = defaultTextScale; timerText.setColorForAllLetters(Colors.HighlightText); // timer.alignMode = UITextAlignMode.Center; }
void Start() { // setup our text instance which will parse our .fnt file and allow us to var text = new UIText( "prototype", "prototype.png" ); text.alignMode = UITextAlignMode.Center; // add a text instance that we will animate later text1 = text.addTextInstance( "hello man. I have a line\nbreak.", Screen.width / 2, 0 ); text2 = text.addTextInstance( _counter.ToString(), Screen.width, 35, 1, 5, Color.black, UITextAlignMode.Right, UITextVerticalAlignMode.Middle ); StartCoroutine( modifyTextInstance() ); }
void Start() { // setup our text instance which will parse our .fnt file and allow us to var text = new UIText("prototype", "prototype.png"); text.alignMode = UITextAlignMode.Center; // add a text instance that we will animate later text1 = text.addTextInstance("hello man. I have a line\nbreak.", Screen.width / 2, 0); text2 = text.addTextInstance(_counter.ToString(), Screen.width, 35, 1, 5, Color.black, UITextAlignMode.Right, UITextVerticalAlignMode.Middle); StartCoroutine(modifyTextInstance()); }
void Start() { text = UIHelper.getText(); var x = Screen.width / 2 + 100; var y = Screen.height / 2 - 210; comboText = text.addTextInstance("X", x, y); comboText.setColorForAllLetters(Colors.HighlightText); comboText.alignMode = UITextAlignMode.Center; comboText.verticalAlignMode = UITextVerticalAlignMode.Middle; comboText.hidden = true; comboText.textScale = 2; }
public static void setTextWrap(UITextInstance text, float lineWrapWidth) { text._parentText.wrapMode = UITextLineWrapMode.MinimumLength; text._parentText.lineWrapWidth = lineWrapWidth; // Re-adding the text to itself, to work around a bug. // TODO: See if there is a better way to do this. Also the wrapping is not working 100% well // some lines are being wrapped early. This could be because we are getting the text from a string instead // of a file. Something that I encountered with my arabic text testing. string content = text.text; text.clear(); text.text = content; }
public static bool textNeedsWrap(UITextInstance text, UIObject fitter, int sideOffset) { float fitterWidth = fitter.width * fitter.scale.x; // If the text is smaller then we're done. if (text.width < fitterWidth - sideOffset) { return(false); } else { return(true); } }
void createLoadingScreen() { //rgbMasterText = infoTextManager.addTextInstance("Bacca is now the RGB master!!!", 0, 0); //rgbMasterText.positionCenter(); loadingText = textManager.addTextInstance("Loading...", 0, 0); //loadingText.positionFromBottomRight(0.01f, 0.01f); loadingText.positionCenter(); //istanzio la evo che ruota per l'effetto caricamento GameObject loadingObj = Instantiate(loadingEffect, Vector3.zero, Quaternion.identity) as GameObject; loadingObj.transform.parent = transform.parent; //lo metto figlio dell'oggetto da distruggere al caricamento loadingObj.transform.position = new Vector3(4.5f, 0.15f, 0); }
// Use this for initialization void Start() { //cameraController = (GameCamera) GameCamera.GetComponent(typeof(GameCamera)); cameraController = GameCamera.GetComponent <GameCamera>(); // create some text ScoreboardText = new UIText("Trebuchet14", "Trebuchet14.png"); ScoreboardTextInstance = ScoreboardText.addTextInstance("Initial Setup", 0f, 0f, 1f, 0); ScoreboardTextInstance.positionFromTop(0.05f); // todo set gametype based on menu choice //GameType = GameTypes.Single; State = States.Null; SetupGame(LoadingGame, GameType); }
// Use this for initialization void Start() { var scaleFactor = ScaleFactor.GetScaleFactor(); scoreText = new UIText(textManager, "VogueCyrBold_60_ffffff", "VogueCyrBold_60_ffffff.png"); scoretext1 = scoreText.addTextInstance(string.Format("{0}", Main.getScore()), 0, 0); scoretext1.color = Color.black; scoretext1.textScale /= scaleFactor * 0.4f; if (Application.loadedLevelName != "gameOver") { scoretext2 = scoreText.addTextInstance(string.Format("{0}", Main.getTargetScore()), 0, 0); scoretext2.positionFromCenter(0.17f, 0.0f); scoretext2.color = Color.black; } scoretext1.positionFromCenter(0.0f, 0.0f); }
private IEnumerator createCreditsMenu() { Debug.Log("Create OptionsMenu"); currentPage = PageOLD.Credits; if (creditsText == null) { creditsTextManager = new UIText("font", "font.png"); creditsText = creditsTextManager.addTextInstance("Credits, Mamba pro Bacca gay everyday \n nigger nigger nigger", 0, 0); } yield return(null); // Posizioni creditsText.positionCenter(); // Animazione creditsText.positionFrom(1.0f, new Vector3(-Screen.width, creditsText.position.y, creditsText.position.z), Easing.Quartic.easeIn); }
public static void fitTextHorizontally(UITextInstance text, int sideOffset, UIObject fitter) { float fitterWidth = fitter.width * fitter.scale.x; // If the text is smaller then we're done. if (!textNeedsWrap(text, fitter, sideOffset)) { return; } // Border space is so the text doesn't end at the edge of the containing object. int borderSpace = 5; hd(ref borderSpace); setTextWrap(text, fitterWidth - borderSpace); }
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() ); }
// Use this for initialization void Start() { var scaleFactor = ScaleFactor.GetScaleFactor(); //high score var CloseBtn = UIButton.create(highscoreManager, "back_normal2.png", "back_active2.png", 0, 0); CloseBtn.highlightedTouchOffsets = new UIEdgeOffsets(30); CloseBtn.onTouchUpInside += sender => Application.LoadLevel("AGAIN"); CloseBtn.touchDownSound = audioplay.getSoundClip(); CloseBtn.positionFromCenter(0.18f, 0.05f); CloseBtn.setSize(CloseBtn.width / scaleFactor * 1f, CloseBtn.height / scaleFactor * 1f); highScore = Main.getHighScore(); highScoreText = new UIText(textManager, "VogueCyrBold_60_ffffff", "VogueCyrBold_60_ffffff.png"); highscoretext = highScoreText.addTextInstance(string.Format("{0}", highScore), 0, 0); highscoretext.textScale /= scaleFactor * 0.4f; highscoretext.positionFromCenter(-0.03f, 0.01f); highscoretext.color = Color.black; }
public static void addTextToScrollable(UIScrollableVerticalLayout layout, UITextInstance text, UIToolkit uiTools) { UISprite textWrapper; bool wrapperAlreadyAdded = false; setTextLayoutWrap(layout, text); if (layout.TextWrapper == null) { textWrapper = createTextWrapper(uiTools, text, layout); layout.TextWrapper = textWrapper; } else { textWrapper = layout.TextWrapper; wrapperAlreadyAdded = true; if (textWrapper.userData != null) { Debug.Log("textWrapper has userData. NEED TO DELETE IT?"); // TODO: Need to add some checking here for safety. UITextInstance oldText = (UITextInstance)textWrapper.userData; if (oldText != text) { Debug.Log("Removing the old text from the textWrapper.userData by unparenting it"); oldText.parentUIObject = null; textWrapper.userData = null; } textWrapperScale(layout, textWrapper, text); text.parentUIObject = textWrapper; textWrapper.userData = text; textPositionInWrapper(text); } } if (!wrapperAlreadyAdded) { layout.addChild(textWrapper); } }
public static void addTextToScrollable( UIScrollableVerticalLayout layout, UITextInstance text, UIToolkit uiTools ) { UISprite textWrapper; bool wrapperAlreadyAdded = false; setTextLayoutWrap( layout, text ); if( layout.TextWrapper == null ) { textWrapper = createTextWrapper( uiTools, text, layout ); layout.TextWrapper = textWrapper; } else { textWrapper = layout.TextWrapper; wrapperAlreadyAdded = true; if( textWrapper.userData != null ) { Debug.Log( "textWrapper has userData. NEED TO DELETE IT?" ); // TODO: Need to add some checking here for safety. UITextInstance oldText = (UITextInstance)textWrapper.userData; if( oldText != text ) { Debug.Log( "Removing the old text from the textWrapper.userData by unparenting it" ); oldText.parentUIObject = null; textWrapper.userData = null; } textWrapperScale( layout, textWrapper, text ); text.parentUIObject = textWrapper; textWrapper.userData = text; textPositionInWrapper( text ); } } if( !wrapperAlreadyAdded ) { layout.addChild( textWrapper ); } }
public static UISprite createTextWrapper(UIToolkit uiTools, UITextInstance text, UIAbstractContainer layout) { // Get the right wrapping for the text setTextLayoutWrap(layout, text); // Create the wrapper and scale it // TODO: Check if empty.png exists if not then throw a clear error. UISprite textWrapper = uiTools.addSprite("empty.png", 0, 0); textWrapperScale(layout, textWrapper, text); // Make the text a child of the wrapper text.parentUIObject = textWrapper; textWrapper.userData = text; textPositionInWrapper(text); // Return the wrapper return(textWrapper); }
private void createLandingScreen() { stadiumBG = uiTools.addSprite("stadiumBG.png", 0, 0, 20); UISprite titleSprite = uiTools.addSprite("title.png", 0, 0, 20); titleSprite.pixelsFromTop(28); int buttonsBottomOffset = 130; // Start Button UIButton startButton = UIButton.create(uiTools, "dieButtonLarge.png", "dieButtonLargeDown.png", 0, 0, 10); startButton.pixelsFromBottomLeft(buttonsBottomOffset, 13); UITextInstance startText = graph26.addTextInstance(" START ", 0, 0); startText.parentUIObject = startButton; startText.pixelsFromTopRight(52, 0); // Options Button UIButton optionsButton = UIButton.create(uiTools, "dieButtonLarge.png", "dieButtonLargeDown.png", 0, 0, 10); optionsButton.pixelsFromBottomRight(buttonsBottomOffset, 50); UITextInstance optionsText = graph20.addTextInstance("OPTIONS", 0, 0); optionsText.parentUIObject = optionsButton; optionsText.pixelsFromTopRight(56, 5); // Parent everything to the landingParent for moving UIObject[] objects = { titleSprite, startButton, startText, optionsButton, optionsText }; foreach (UIObject item in objects) { item.parentUIObject = landingParent; } // Set button actions startButton.onTouchUpInside += (sender) => showStartScreen(); }
public static void centerText(UITextInstance txt, int pixelOffset, int buttonOffset) { float parentHeight = txt.parentUIObject.height * txt.parentUIObject.scale.y; float height = txt.height; float parentWidth = txt.parentUIObject.width * txt.parentUIObject.scale.x; float width = txt.width; hd(ref pixelOffset); hd(ref buttonOffset); if (pixelOffset == 0 && buttonOffset == 0) { /* Commenting this out. It is not centering correctly for some reason * txt.verticalAlignMode = UITextVerticalAlignMode.Middle; * txt.positionCenter(); */ txt.verticalAlignMode = UITextVerticalAlignMode.Middle; int offsetTop = (int)(parentHeight / 2) - (int)(height / 2); if (offsetTop < 0) { offsetTop *= -1; } txt.pixelsFromTop(offsetTop, 0); } else { txt.verticalAlignMode = UITextVerticalAlignMode.Top; int offsetTop = (int)((parentHeight - height) / 2) - pixelOffset; if (offsetTop < 0) { offsetTop *= -1; } //txt.pixelsFromTop(offset); txt.pixelsFromTopLeft(offsetTop, (int)((parentWidth - width) / 2) + buttonOffset); } }
public static void centerText( UITextInstance txt, int pixelOffset, int buttonOffset ) { float parentHeight = txt.parentUIObject.height * txt.parentUIObject.scale.y; float height = txt.height; float parentWidth = txt.parentUIObject.width * txt.parentUIObject.scale.x; float width = txt.width; hd( ref pixelOffset ); hd( ref buttonOffset ); if (pixelOffset == 0 && buttonOffset == 0) { /* Commenting this out. It is not centering correctly for some reason txt.verticalAlignMode = UITextVerticalAlignMode.Middle; txt.positionCenter(); */ txt.verticalAlignMode = UITextVerticalAlignMode.Middle; int offsetTop = (int)(parentHeight/2) - (int)(height/2); if( offsetTop < 0 ) { offsetTop *= -1; } txt.pixelsFromTop( offsetTop, 0 ); } else { txt.verticalAlignMode = UITextVerticalAlignMode.Top; int offsetTop = (int)(( parentHeight - height )/2) - pixelOffset; if( offsetTop < 0 ) { offsetTop *= -1; } //txt.pixelsFromTop(offset); txt.pixelsFromTopLeft( offsetTop, (int)((parentWidth - width)/2) + buttonOffset ); } }
public void setHiddenForTextInstance( ref UITextInstance textInstance, bool value ) { if (textInstance.textIndex < _textSprites.Count) { int length = _textSprites[textInstance.textIndex].Length; for ( int i = 0; i < length; i++ ) _textSprites[textInstance.textIndex][i].hidden = value; } }
public void updateColorForTextInstance( ref UITextInstance textInstance ) { // how many sprites are we updated? int length = _textSprites[textInstance.textIndex].Length; // we either make all the letters the same color or each letter a different color if( textInstance.colors.Length == 1 ) { for( int i = 0; i < length; i++ ) _textSprites[textInstance.textIndex][i].color = textInstance.colors[0]; } else { for( int i = 0; i < length; i++ ) _textSprites[textInstance.textIndex][i].color = textInstance.colors[i]; } }
public static void centerText(UITextInstance txt) { centerText( txt, 0, 0 ); }
public UITextInstance addTextInstance( string text, float xPos, float yPos, float scale, int depth, Color[] colors, UITextAlignMode alignMode, UITextVerticalAlignMode verticalAlignMode ) { if( forceLowAscii ) forceLowAsciiString( ref text ); var textInstance = new UITextInstance( this, text, xPos, yPos, scale, depth, colors, alignMode, verticalAlignMode ); textInstance.textIndex = drawText( text, xPos, yPos, scale, depth, colors, textInstance.alignMode, textInstance.verticalAlignMode ); return textInstance; }
public void updateText( ref UITextInstance textInstance ) { // kill the current text then draw some new text deleteText( textInstance.textIndex ); textInstance.textIndex = drawText( textInstance.text, textInstance.xPos, textInstance.yPos, textInstance.scale, textInstance.depth, textInstance.color ); }
public static bool textNeedsWrap( UITextInstance text, UIObject fitter, int sideOffset ) { float fitterWidth = fitter.width * fitter.scale.x; // If the text is smaller then we're done. if( text.width < fitterWidth - sideOffset ) { return false; } else { return true; } }
public void updateText( UITextInstance textInstance ) { // if our textInstance has a localScale of anything other than (1, 1, z), the child sprites generated here will have a weird local scale as well. // so, lets reset our text instance to (1, 1, z) and then restore the previous local scale after drawText Vector3 originalScale = textInstance.localScale; bool scaleChanged = false; if (originalScale.x != 1f || originalScale.y != 1f) { textInstance.localScale = new Vector3(1f, 1f, originalScale.z); scaleChanged = true; } // kill the current text then draw some new text drawText( textInstance, textInstance.xPos, textInstance.yPos, textInstance.textScale, textInstance.depth, textInstance.colors, textInstance.alignMode, textInstance.verticalAlignMode ); // now restore the originalScale scale if (scaleChanged) { textInstance.localScale = originalScale; } }
public UITextInstance addTextInstance( string text, float xPos, float yPos, float scale, int depth, Color color ) { var textInstance = new UITextInstance( this, text, xPos, yPos, scale, depth, color ); textInstance.textIndex = drawText( text, xPos, yPos, scale, depth, color ); return textInstance; }
public void updateText( UITextInstance textInstance ) { // kill the current text then draw some new text drawText( textInstance, textInstance.xPos, textInstance.yPos, textInstance.textScale, textInstance.depth, textInstance.colors, textInstance.alignMode, textInstance.verticalAlignMode ); }
/// <summary> /// Draw text on screen, create each quad and send it to the manager /// </summary> private void drawText( UITextInstance textInstance, float xPos, float yPos, float scale, int depth, Color[] color, UITextAlignMode instanceAlignMode, UITextVerticalAlignMode instanceVerticalAlignMode ) { // Start by resetting textInstance position textInstance.position = Vector3.zero; bool hidden = textInstance.hidden; float dx = 0; float dy = 0; float offsetY; int fontLineSkip = 0; int charId = 0; // Perform word wrapping ahead of sprite allocation! var text = textInstance.text; text = wrapText( text, scale ); int lineStartChar = 0; int lineEndChar = 0; float totalHeight = ( _fontDetails[ASCII_LINEHEIGHT_REFERENCE].h * scale * lineSpacing ); for( var i = 0; i < text.Length; i++ ) { charId = System.Convert.ToInt32( text[i] ); if( charId == ASCII_NEWLINE ) { // calculate the size to center text on Y axis, based on its scale // 77 is the "M" char usually big enough to get a proper spaced // lineskip, use any other char if you want fontLineSkip += (int)( _fontDetails[ASCII_LINEHEIGHT_REFERENCE].h * scale * lineSpacing ); totalHeight += (int)( _fontDetails[ASCII_LINEHEIGHT_REFERENCE].h * scale * lineSpacing ); alignLine( textInstance.textSprites, lineStartChar, lineEndChar, dx, instanceAlignMode ); lineStartChar = i + 1; dx = 0; } else { // calculate the size to center text on Y axis, based on its scale offsetY = _fontDetails[charId].offsety * scale; dy = offsetY + fontLineSkip; } // Extend end of line lineEndChar = i; // add quads for each char // Use curpos instead of i to compensate for line wrapping hyphenation // reuse a UISprite if we have one. if we don't, we need to set it's parent and add it to the textInstance's list var currentTextSprite = textInstance.textSpriteAtIndex( i ); var addingNewTextSprite = currentTextSprite == null; currentTextSprite = configureSpriteForCharId( currentTextSprite, charId, dx, dy, scale, 0 ); if( addingNewTextSprite ) { currentTextSprite.color = color.Length == 1 ? color[0] : color[i]; currentTextSprite.parentUIObject = textInstance; textInstance.textSprites.Add( currentTextSprite ); } // Ensure the sprite is hidden if the textInstance is currentTextSprite.hidden = hidden; // See below @NOTE re: offsetx vs. xadvance bugfix. // advance the position to draw the next letter dx += _fontDetails[charId].xadvance * scale; } alignLine( textInstance.textSprites, lineStartChar, lineEndChar, dx, instanceAlignMode ); verticalAlignText( textInstance.textSprites, totalHeight, _fontDetails[ASCII_LINEHEIGHT_REFERENCE].offsety * scale * lineSpacing, instanceVerticalAlignMode ); // Re-position textInstance textInstance.position = new Vector3(xPos, yPos, depth); }
void Start() { m_ui = GameObject.Find("UIToolkit-Score").GetComponent<UIToolkit>(); m_uiText = GameObject.Find("UIToolkit-Scoretext").GetComponent<UIToolkit>(); //--- Fond sombre //m_mask = m_ui.addSprite("selected_background.png", 0, 0); //m_mask.position = new Vector3(-1, -1, -5f); //m_mask.setSize(Screen.width + 1, -Screen.height + 1); //m_mask.hidden = true; //--- //--- Texte de score UIText text = new UIText(m_uiText, "prototype", "prototype.png"); if (IsTop) { _txtScore = text.addTextInstance("$0", 0.1f * Screen.width, -Screen.height * 0.41f, -0.8f, -6, Color.yellow, UITextAlignMode.Center, UITextVerticalAlignMode.Top); _txtScoreTotal = text.addTextInstance("Total\r\n\r\n$0", 0.305f * Screen.width, -Screen.height * 0.36f, -0.5f, -6, new Color(1f, 1f, 1f, 0.5f), UITextAlignMode.Left, UITextVerticalAlignMode.Bottom); } else { _txtScore = text.addTextInstance("$0", 0.395f * Screen.width, -Screen.height * 0.084f, 0.8f, -6, Color.yellow, UITextAlignMode.Center, UITextVerticalAlignMode.Bottom); _txtScoreTotal = text.addTextInstance("Total\r\n\r\n$0", 0.2f * Screen.width, -Screen.height * 0.14f, 0.5f, -6, new Color(1f, 1f, 1f, 0.5f), UITextAlignMode.Left, UITextVerticalAlignMode.Bottom); } _txtScore.hidden = true; _txtScoreTotal.hidden = true; //--- }
public UISprite[] returnTextSprite( ref UITextInstance textInstance) { return _textSprites[textInstance.textIndex]; }
public static void fitTextHorizontally( UITextInstance text, int sideOffset, UIObject fitter ) { float fitterWidth = fitter.width * fitter.scale.x; // If the text is smaller then we're done. if( !textNeedsWrap( text, fitter, sideOffset ) ) { return; } // Border space is so the text doesn't end at the edge of the containing object. int borderSpace = 5; hd( ref borderSpace ); setTextWrap( text, fitterWidth - borderSpace ); }
public static void setTextLayoutWrap( UIAbstractContainer layout, UITextInstance text ) { setTextWrap( text, layout.width - layout.edgeInsets.right ); }
public static void textWrapperScale( UIAbstractContainer layout, UISprite textWrapper, UITextInstance text ) { Vector2 textDimensions = text._parentText.sizeForText( text.text ); textWrapper.scale = (new Vector3(layout.width / 5, textDimensions.y / 5, 1)); }
// Use this for initialization void Start() { stage = GameObject.Find( "Floor").GetComponent<Stage>(); GameObject objUser = GameObject.Find( "User"); statusUser = objUser.GetComponent<StatusUser>(); motionUser = objUser.GetComponent<MotionUser>(); attackUser = objUser.GetComponent<AttackUser>(); motionCamera = Camera.mainCamera.GetComponent<MotionCamera>(); // Se calcula la relación entre la resolución virtual de referencia y la resolución actual de pantalla fRatioX = Screen.width * 1.0f / iWidthScreen; fRatioY = Screen.height * 1.0f / iHeightScreen; // Se crea la barra de energía y se inicializan los parámetros relacionados. barUserEnergy = UIStateSprite.create( "Energy.png", 0, 0); barUserEnergy.hidden = false; barGunEnergy = UIStateSprite.create( "Level.png", 0, 0); barGunEnergy.hidden = false; textKilled = new UIText( "prototype", "prototype.png"); textEnemies = new UIText( "prototype", "prototype.png"); textRecord = new UIText( "prototype", "prototype.png"); textEnemiesInstance = textEnemies.addTextInstance( "Enemigos: 0", iXTextEnemies * fRatioX, iYTextEnemies * fRatioY, 0.8f, 1, Color.green); textKilledInstance = textKilled.addTextInstance( "Asesinatos: 0", iXTextKilled * fRatioX, iYTextKilled * fRatioY, 0.8f, 1, Color.red); textRecordInstance = textRecord.addTextInstance( "Record: " + PlayerPrefs.GetInt( "Record", 0), iXTextRecord * fRatioX, iYTextRecord * fRatioY, 0.8f, 1, Color.black); buttonPersp = UIButton.create( "emptyUp.png", "emptyDown.png", 0, 0); buttonPersp.hidden = false; textPersp = new UIText( "prototype", "prototype.png"); textPerspInstance = textPersp.addTextInstance( motionCamera.strCameraPersp, iXTextPersp * fRatioX, iYTextPersp * fRatioY, 0.9f, 1, Color.blue); }
public static void centerText(UITextInstance txt, int pixelOffset) { centerText( txt, pixelOffset, 0 ); }
public void updateColorForTextInstance( ref UITextInstance textInstance ) { // how many sprites are we updated? int length = _textSprites[textInstance.textIndex].Length; for( int i = 0; i < length; i++ ) _textSprites[textInstance.textIndex][i].color = textInstance.color; }
public static void setTextWrap( UITextInstance text, float lineWrapWidth ) { text._parentText.wrapMode = UITextLineWrapMode.MinimumLength; text._parentText.lineWrapWidth = lineWrapWidth; // Re-adding the text to itself, to work around a bug. // TODO: See if there is a better way to do this. Also the wrapping is not working 100% well // some lines are being wrapped early. This could be because we are getting the text from a string instead // of a file. Something that I encountered with my arabic text testing. string content = text.text; text.clear(); text.text = content; }
public static void textPositionInWrapper(UITextInstance text) { int textOffset = 4; hd( ref textOffset ); text.pixelsFromTopLeft( textOffset, textOffset ); }
// Use this for initialization void Start() { //cameraController = (GameCamera) GameCamera.GetComponent(typeof(GameCamera)); cameraController = GameCamera.GetComponent<GameCamera>(); // create some text ScoreboardText = new UIText( "Trebuchet14", "Trebuchet14.png" ); ScoreboardTextInstance = ScoreboardText.addTextInstance( "Initial Setup", 0f, 0f, 1f, 0 ); ScoreboardTextInstance.positionFromTop( 0.05f ); // todo set gametype based on menu choice //GameType = GameTypes.Single; State = States.Null; SetupGame( LoadingGame, GameType ); }