private void OnGUI() { var size = new Vector2(0.3f, 0.3f); var center = new Vector2(0.5f, 0.7f); var halfSize = size / 2; var topLeft = center - size / 2; // Dibuja ese fondo negroso del menu. GUI.Box(new Rect(Screen.width * topLeft.x, 0, Screen.width * size.x, Screen.height), ""); var boxStyle = new GUIStyle(); boxStyle.alignment = TextAnchor.MiddleCenter; var labelStyle = CustomStyle.GetLabelStyle(); labelStyle.alignment = TextAnchor.MiddleCenter; CustomStyle.SetStyleData(GUI.skin.GetStyle("button")); var menuRect = new Rect( Screen.width * (topLeft.x + halfSize.x * (timeCounter - 1) * -1), Screen.height * (topLeft.y + halfSize.y * (timeCounter - 1) * -1), Screen.width * size.x * timeCounter, Screen.height * size.y * timeCounter); GUI.enabled = transition == UITransitionState.Steady; switch (state) { case MainMenuState.HighScore: DrawHighScore(boxStyle, labelStyle, menuRect); break; case MainMenuState.Credits: DrawCredits(boxStyle, labelStyle, menuRect); break; case MainMenuState.Title: default: DrawTitle(boxStyle, menuRect); break; case MainMenuState.NothingToDraw: break; } }
public void OnGUI() { var style = CustomStyle.GetLabelStyle(); style.alignment = TextAnchor.UpperLeft; GUILayout.BeginArea(new Rect(5, 5, 300, 100)); { GUILayout.BeginVertical(); { GUILayout.Label(string.Format("Lives: {0}", currentLives)); if (playerSpecial.powerController != null) { GUILayout.Label(string.Format("{0} x{1}", playerSpecial.powerController.SpecialName, playerSpecial.powerCount)); } else { GUILayout.Label("No Powerup"); } } } GUILayout.EndArea(); if (showHighScoreBox) { var boxStyle = GUI.skin.GetStyle("box"); boxStyle.alignment = TextAnchor.MiddleCenter; CustomStyle.SetStyleData(GUI.skin.GetStyle("button")); var size = new Vector2(0.2f, 0.2f); var center = new Vector2(0.5f, 0.5f); var halfSize = size / 2; var topLeft = center - size / 2; var menuRect = new Rect( Screen.width * (topLeft.x + halfSize.x * (timeCounter - 1) * -1), Screen.height * (topLeft.y + halfSize.y * (timeCounter - 1) * -1), Screen.width * size.x * timeCounter, Screen.height * size.y * timeCounter); style.alignment = TextAnchor.MiddleCenter; GUILayout.BeginArea(menuRect, boxStyle); GUILayout.BeginVertical(); { GUI.enabled = transition == UITransitionState.Steady; GUILayout.FlexibleSpace(); style.alignment = TextAnchor.MiddleCenter; GUILayout.Label("Nuevo High Score!"); GUILayout.FlexibleSpace(); var textStyle = GUI.skin.GetStyle("textfield"); textStyle.fontSize = 24; textStyle.font = CustomStyle.font; winnerName = GUILayout.TextField(winnerName, 5); if (GUILayout.Button("Guardar")) { scoreController.SaveHighScore(winnerName); timeCounter = 1; transition = UITransitionState.EasingOut; waitToReturnToTitleScreen = true; } } GUILayout.EndVertical(); GUILayout.EndArea(); } }