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
Unity greatly simplifies the process of designing user interfaces (UI) by offering automatic layout components. These allow you to create complex UI shapes without the need for manual adjustments. These components are very useful, especially when interface elements must adapt to various screen resolutions or when they are dynamically generated during execution.
When you want to align elements, such as buttons, in a row from left to right, the Horizontal Layout Group
component is the ideal solution. This component automatically arranges elements as they are duplicated, deleted or resized, improving the visual consistency of the UI on different devices and resolutions.
// Example of use in UnityElementContent.GetComponent<HorizontalLayoutGroup>().childForceExpandWidth = true;ElementContent.GetComponent<HorizontalLayoutGroup>().childForceExpandHeight = true;
This component is similar to the Horizontal Layout Group
, but organizes elements vertically, from top to bottom. It is useful when you want to create lists or panels that grow vertically.
For a uniform grid layout of elements, the Grid Layout Group
is used. This component organizes elements in a grid layout by defining a consistent size for each cell, which is beneficial for displaying collections such as image galleries or item grids.
// Settings for a gridElementContent.GetComponent<GridLayoutGroup>().cellSize = new Vector2(100, 100);ElementContent.GetComponent<GridLayoutGroup>().spacing = new Vector2(10, 10);
The Content Size Fitter
is a component that allows the size of a parent element to be dynamically adjusted according to the child elements. It is ideal for interfaces that must adapt to variable content, where the number or size of elements is indeterminate.
// Content Size Fitter implementationElementContent.AddComponent<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize;
The true power of these layout components in Unity is unleashed by combining them. For example, you can create containers with a Horizontal Layout Group
inside another container that uses a Vertical Layout Group
, which generates complex and responsive interfaces. In addition, combined use with Content Size Fitter
ensures that all elements adapt to their content, no matter how much it varies.
The key is to experiment with different configurations and combinations to see how much you can simplify the creation of visually cohesive interfaces. Have you tried these components in your Unity projects? Leave your experiences and questions in the comments - keep exploring and learning!
Contributions 0
Questions 0
Want to see more contributions, questions and answers from the community?