Introducci贸n a las herramientas de desarrollo para videojuegos
Introducci贸n
Qu茅 son las herramientas de desarrollo
Herramientas m谩s comunes en el mundo del desarrollo de videojuegos
Dibujando en el editor
Sistema IMGUI y Ciclo de vida de Editor
Controles: creando un bot贸n
Creaci贸n de toolbar y gui
Gizmos
Handles
Pr谩cticando en el editor
Shortcuts 煤tiles del editor
Context Menus
Menu Item
Herramientas de Editor
Attributes y Property drawers
Iniciando nuestro custom Editor
Serialized properties
Optimizando nuestro custom editor
Guardar y cargar data de herramientas: json, scriptable objects, txt y csv
Encontrar assets para editor window
Editor windows: mostrando datos en el editor
Editor windows: agregando funcionalidades
Cierre del curso
Cierre del curso
You don't have access to this class
Keep learning! Join and start boosting your career
When working on projects within Unity, customizing the inspector can significantly improve the user and designer experience. Customizing the inspector allows you to display only the relevant elements and properties, which makes it easier to manage and edit content efficiently.
To start customizing the inspector, we must make sure that the properties are stored correctly. We can go into "debug mode" in Unity to check that the information is saved properly, even if it is not visible in the GUI while we are in normal mode. The next step is to work on the code to start drawing the inspector in a more visual and functional way.
Next, we use GUILayout
to make the design process easier. For example, we can create an object field
that allows us to enter references, such as when adding an icon to the sprite renderer
. This is accomplished by passing a specific property to the object field
and setting up an empty GUIContent
for the inspector's aesthetics.
// Create an Object Field for the icon propertyicon = (Sprite)EditorGUILayout.ObjectField("", icon, typeof(Sprite), false);
To visually enrich our inspector, it is useful to display a preview of the icon. Unity offers several classes that allow to preview thumbnails and assets. We use AssetPreview
to get a 2D image of the icon to handle.
// Get the preview of the icon as aTexture2D textureiconPreview = AssetPreview.GetAssetPreview(icon);
Subsequently, the texture is drawn using EditorGUI
so that it is clearly visible in the inspector. This way you can evaluate if the icon is in the desired format.
// Draw the icon texture in the inspectorGUILayout.Label(iconPreview, GUILayout.Width(100), GUILayout.Height(100));
The layout of elements is crucial for an efficient user interface. You can use GUILayout
to create groups of controls, arranging the elements horizontally or vertically as needed.
// Create a horizontal group to align elementsGUILayout.BeginHorizontal();GUILayout.EndHorizontal();
This type of organization ensures a clear and logical arrangement of information, allowing designers to quickly understand which properties to adjust.
When working with editable properties in the inspector, it is crucial to correctly manage their changes to ensure that any modifications are properly saved. This is achieved by updating the serialized object each time the GUI is edited.
// Update and apply changes to the serialized objectserializedObject.Update();EditorGUILayout.PropertyField(property);serializedObject.ApplyModifiedProperties();
Additionally, a decision system can be implemented by means of a switch statement
to select which properties to display according to the defined object type. This allows for a dynamic and flexible inspector that solves common problems when designing interactive elements.
Customizing the inspector in Unity not only improves the display of content, but also optimizes the workflow for designers:
By integrating these settings into larger projects, collaboration in development teams is strengthened, allowing designers to focus on the creative aspects without worrying about unnecessary technical details. This boost in productivity and clarity translates into higher quality deliverables.
Contributions 0
Questions 0
Want to see more contributions, questions and answers from the community?