Main Menu Stylization
Pyyhkäise näyttääksesi valikon
Stylizing the Main Menu and Adding Interactive Player Preview
Once your main menu works functionally, it's time to make it visually appealing and interactive.
Custom Fonts and UI Styling
- select your UI Text elements (buttons, labels, titles);
- assign custom fonts and vibrant colours;
- move interactive elements (buttons, dropdowns) to the bottom of the Hierarchy to ensure they aren't covered by other UI or background elements.
Adding Backgrounds and Animated Player
- add background, floor, or decorative sprites as UI images to give depth;
- copy the player
GameObjectfrom the game scene to the menu for animation preview; - remove unnecessary components (e.g.
Rigidbody2D,PlayerController) so the player is static but animated.
Change the Canvas type from Overlay -> Screen Space - Camera and assign your main camera.
This allows the player and background to render properly in front of each other.
Buttons and Dropdown Styling
- apply a custom sprite to button backgrounds;
- adjust text and button dimensions to match the visual style.
Displaying Highscore in Menu
- add UI -> TextMeshPro - Text elements: one writing
"Highscore:"and one for the highscore value; - reference the
PlayerPrefshighscore value in the menuCanvas; - optionally scale it (e.g.
highScore * 10) for emphasis.
Extra Touch: Quick Menu Access
In the Level scene, you can let the player return to the main menu by checking for Escape key input:
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
SceneManager.LoadScene("MainMenu");
}
}
1. How can you display the animated player in the main menu so that it appears animated but does not move or respond to gameplay scripts
?
2. Why do you change the Canvas type from Overlay to Screen Space – Camera in the main menu?
3. You notice that dropdowns or buttons sometimes get covered by other UI elements in the menu. What’s the simplest way to fix this?
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 6. Luku 3
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme
Osio 6. Luku 3