Introducci贸n
Bienvenida y presentaci贸n del proyecto
Instalaci贸n de los SDKs
Empezando Nuestro Proyecto
Inicializar el proyecto
Control de versiones
Importando nuestros assets
Teor铆a de Gameplay
Como resolver problemas de gameplay
Match 3 simplificado
Mec谩nica Principal
Creando la cuadr铆cula
Ajustando la c谩mara
Sistema de coordenadas para instanciar las piezas
Instanciando las piezas en la cuadr铆cula
Moviendo las piezas
Intercambiando las piezas de lugar
Permitiendo solo ciertos tipos de movimientos
Creando las funciones del match 3
Usando el match 3 en nuestro juego
Eliminando los matches por defecto
Colapsando las piezas
Match 3 combo
Rellenando las piezas
Mejorando la animaci贸n de las piezas
Publicacion
Momento del primer build para Android
Momento del primer build para iOS
Dise帽o del juego
Hablemos de dise帽o
Agregando un sistema de puntos
Sistema de tiempo
Interfaz para el sistema de tiempo
Creando sistema de UI
Pantalla de game over
Agregando funcionalidad a la pantalla de game over
Reiniciando el juego
Agregando audio
Terminando el juego
Conclusiones
Conclusiones del curso
You don't have access to this class
Keep learning! Join and start boosting your career
Creating graphical interfaces in Unity may seem challenging, but with a little programming and design it is possible to achieve nice and functional transitions. In this class, we will focus on developing a UI system that facilitates interaction with players by displaying screens associated with different game states, such as the start or end of a game. Join me and discover how to connect your scripts and create an engaging user experience in Unity.
First of all, we need to make sure that our event logic in Unity is set up properly. One of the most powerful events is the Unity Event
, which allows us to have different sections of the code listen and respond appropriately to changes in game state.
Edit the Game Manager:
Add a new Unity event with parameters. This is done by adding Public Unity Event On Game State Updated
followed by the parameter type, which in this case is Game State
.
Modify the Update
function to trigger this event when the game changes state, for example, when a game is lost.
if (currentState == GameState.GameOver) { OnGameStateUpdated?.Invoke(currentState);}
This allows other scripts to subscribe to the event and act accordingly.
Once we solve the event part, the next thing is to create a base UI screen that reacts when the game state changes.
Create a C# script for UIScreen:
UIScreen
where you will define the necessary properties like RectTransform
, CanvasGroup
and the GameState
property.public RectTransform containerRect;public CanvasGroup containerCanvas;public Image background;public GameManager.GameState visible State;public float transitionTime;
Subscribe to the event from the UIScreen script:
Start
function, subscribe the script to the OnGameStateUpdated
event.void Start() { GameManager.instance.OnGameStateUpdated.AddListener(GameStateUpdated);}
Defines the initial behavior and its transitions:
GameStateUpdated
function to show or hide screens depending on the state of the game.void GameStateUpdated(GameManager.GameState newState) { if (newState == visibleState) { ShowScreen(); } else { HideScreen(); } }}
Visual transitions enhance the user experience, and using DOTween
, you can make smooth animations in interfaces.
Configure animations in ShowScreen and HideScreen:
void ShowScreen() { background.enabled = true; containerCanvas.alpha = 0; containerRect.anchoredPosition = new Vector2(0, 100); containerCanvas.DOFade(1, transitionTime); containerRect.DOAnchorPos(Vector2.zero, transitionTime);}
void HideScreen() { containerCanvas.DOFade(0, transitionTime * 0.5f); containerRect.DOAnchorPos(new Vector2(0, -100), transitionTime * 0.5f).OnComplete((() => { background.enabled = false; containerRect.gameObject.SetActive(false); });} ).
With these configurations, you have implemented an effective system that shows and hides screens based on the state of the game. We encourage you to try and practice these steps in Unity to refine your GUI development skills - go ahead and learn!
Contributions 1
Questions 0
Want to see more contributions, questions and answers from the community?