Introducción y configuración inicial
Bienvenida al curso
Cargando el proyecto
El sistema de UI de Unity
El sistema de UI de Unity
El componente Canvas
El Rect Transform
Componente de imagen
Máscaras y efectos
Cómo crear texto en Unity
Creando botones en nuestra interfaz
Otros elementos de UI
Auto layout
Scroll views
Canvas groups
Haciendo interfaces para el juego
Revisión de las interfaces del juego
Importando nuestros assets
Diagramación de la pantalla del título
Animando el fondo con shader graph
Agregando lógica a la pantalla de título
Diagramación de la pantalla de selección de nivel
Implementación pantalla de selección de nivel
Ajustando el sistema de interfaz
Mejora de la interfaz del juego
Implementando la interfaz del juego
Diagramando la pantalla de pausa
Implementando la pantalla de pausa
Mejorando la pantalla de Game Over
Diagramación de la pantalla de configuración
Implementación de la pantalla de configuración
Muestra final y conclusiones
You don't have access to this class
Keep learning! Join and start boosting your career
To get closer to implementing an options screen in our game, we need to start with the creation of a new state in our GameManager
. This new state will be crucial to manage the proper transition to the options screen.
GameManager
file, we include a new GameState
called Options
.public void Options()
, setting the game state to GameState.Options.
OnGameStateUpdated()
function to update the game state.public enum GameState { Idle, Options, // other states}
public void Options() { gameState = GameState.Options; OnGameStateUpdated();}
UIStartScreen
script to add a new optionsButtonClick
function, which calls gameManager.instance.Options()
.public void OptionsButtonClick() { gameManager.instance.Options();}
Options
button so that its OnClick
event is bound to optionsButtonClick
.Once the options state is integrated, it is time to configure the audio controls on the screen. This will allow users to set the volume of music and sound effects.
Add UIScreen component:
UIOptions
screen, a UIScreen
component is added to control visibility in the Options
state.Adjust screen layout:
UIOptions
script:public int volume;public int sfx;public TextMeshProUGUI volumeLabel;public TextMeshProUGUI sfxLabel;
public void AddVolume() { volume++; UpdateVolumeLabel();}
public void MinusVolume() { volume--; UpdateVolumeLabel();}
Initialize and update labels:
Add
and Minus
functions.Limit numeric values:
Mathf.Clamp
to limit values between 0 and 10 in all relevant functions when adjusting volume and sound effects.volume = Mathf.Clamp(volume, 0, 10);
Volume
and SFX
to the corresponding functions in UIOptions
.Although we have created a screen that allows you to see volume adjustments, you still need to connect these controls to the internal audio logic. Here are some considerations:
AudioManager
: Look for ways to integrate UIOptions
with the AudioManager
class to realistically effect volume changes.We want to hear from you! Can you think of a way to connect UIOptions
to the AudioManager
class to actually manage volume? Share your solution in the comments and let's help others learn too.
Contributions 1
Questions 0
Want to see more contributions, questions and answers from the community?