Skip to content

Commit a3b8093

Browse files
committed
Texts and comments translated into English
1 parent ead74e0 commit a3b8093

1 file changed

Lines changed: 28 additions & 16 deletions

File tree

Editor/MappingTool/EventSystemAuditor.cs

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,19 @@ public class EventSystemAuditor : EditorWindow
99
{
1010
private Vector2 _scrollPos;
1111
private List<ScriptableObject> _allProjectEvents = new List<ScriptableObject>();
12+
13+
// State management for UI expansion
1214
private Dictionary<ScriptableObject, bool> _expansionStates = new Dictionary<ScriptableObject, bool>();
13-
private Dictionary<ScriptableObject, Dictionary<string, List<UsageDetail>>> _masterResults = new Dictionary<ScriptableObject, Dictionary<string, List<UsageDetail>>>();
15+
16+
// Master data: Event -> Asset Path -> List of specific usages
17+
private Dictionary<ScriptableObject, Dictionary<string, List<UsageDetail>>> _masterResults =
18+
new Dictionary<ScriptableObject, Dictionary<string, List<UsageDetail>>>();
1419

1520
private struct UsageDetail
1621
{
1722
public string GameObjectName;
1823
public string ComponentTypeName;
19-
public Object Context;
24+
public Object Context; // Reference to ping the specific component
2025
}
2126

2227
[MenuItem("Tools/SO Event System Auditor")]
@@ -26,20 +31,20 @@ private struct UsageDetail
2631

2732
private void OnGUI()
2833
{
29-
// --- TOOLBAR SUPERIOR ---
34+
// --- TOP TOOLBAR ---
3035
EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
31-
if (GUILayout.Button("Refrescar y Escanear Proyecto", EditorStyles.toolbarButton)) RefreshAndScanAll();
36+
if (GUILayout.Button("Refresh & Scan Project", EditorStyles.toolbarButton)) RefreshAndScanAll();
3237
GUILayout.FlexibleSpace();
3338

34-
if (GUILayout.Button("Expandir Todo", EditorStyles.toolbarButton)) SetAllExpansion(true);
35-
if (GUILayout.Button("Colapsar Todo", EditorStyles.toolbarButton)) SetAllExpansion(false);
39+
if (GUILayout.Button("Expand All", EditorStyles.toolbarButton)) SetAllExpansion(true);
40+
if (GUILayout.Button("Collapse All", EditorStyles.toolbarButton)) SetAllExpansion(false);
3641
EditorGUILayout.EndHorizontal();
3742

3843
_scrollPos = EditorGUILayout.BeginScrollView(_scrollPos);
3944

4045
if (_allProjectEvents.Count == 0)
4146
{
42-
EditorGUILayout.HelpBox("No se encontraron eventos que implementen ISOEventBase.", MessageType.Info);
47+
EditorGUILayout.HelpBox("No ScriptableObjects implementing ISOEventBase were found in the project.", MessageType.Info);
4348
}
4449

4550
foreach (var ev in _allProjectEvents)
@@ -52,22 +57,23 @@ private void OnGUI()
5257

5358
private void RenderEventGroup(ScriptableObject ev)
5459
{
60+
// Default to expanded if state not found
5561
if (!_expansionStates.ContainsKey(ev)) _expansionStates[ev] = true;
5662
bool expanded = _expansionStates[ev];
5763

58-
// Definimos un estilo que cambie visualmente si está expandido
64+
// Custom Header Style
5965
GUIStyle headerStyle = new GUIStyle(EditorStyles.miniButtonMid);
6066
headerStyle.alignment = TextAnchor.MiddleLeft;
6167
headerStyle.fontStyle = FontStyle.Bold;
6268
headerStyle.fontSize = 11;
6369
headerStyle.fixedHeight = 25;
6470

65-
// Feedback visual: Si está expandido, resaltamos el botón
71+
// Visual Feedback: Highlight background if expanded
6672
if (expanded) GUI.backgroundColor = new Color(0.8f, 0.9f, 1f);
6773

6874
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
6975

70-
// El icono de flecha (foldout) ayuda a entender que es colapsable
76+
// Toggle Button
7177
string arrow = expanded ? "▼" : "▶";
7278
if (GUILayout.Button($" {arrow} {ev.name.ToUpper()} [{ev.GetType().Name}]", headerStyle))
7379
{
@@ -82,15 +88,15 @@ private void RenderEventGroup(ScriptableObject ev)
8288
{
8389
foreach (var assetEntry in _masterResults[ev])
8490
{
85-
// Contenedor para cada Prefab/Escena
91+
// Group by Asset (Prefab/Scene)
8692
EditorGUILayout.BeginVertical(EditorStyles.textArea);
8793
GUILayout.Label($"📂 {System.IO.Path.GetFileName(assetEntry.Key)}", EditorStyles.boldLabel);
8894

8995
foreach (var detail in assetEntry.Value)
9096
{
9197
EditorGUILayout.BeginHorizontal();
9298
GUILayout.Space(15);
93-
// El botón de cada componente para hacer ping
99+
// Deep link to component
94100
if (GUILayout.Button($" # GO: {detail.GameObjectName} ({detail.ComponentTypeName})", EditorStyles.label))
95101
{
96102
EditorGUIUtility.PingObject(detail.Context);
@@ -103,7 +109,7 @@ private void RenderEventGroup(ScriptableObject ev)
103109
}
104110
else
105111
{
106-
EditorGUILayout.LabelField(" No se detectaron usos en el proyecto.", EditorStyles.centeredGreyMiniLabel);
112+
EditorGUILayout.LabelField(" No usages detected in prefabs or scenes.", EditorStyles.centeredGreyMiniLabel);
107113
}
108114
}
109115

@@ -117,25 +123,28 @@ private void SetAllExpansion(bool state)
117123
foreach (var key in keys) _expansionStates[key] = state;
118124
}
119125

120-
// --- LÓGICA DE ESCANEO (Sin cambios significativos para mantener la funcionalidad) ---
126+
// --- SCAN LOGIC ---
127+
121128
private void RefreshAndScanAll()
122129
{
123130
_allProjectEvents.Clear();
124131
_masterResults.Clear();
125132

133+
// 1. Find all relevant SOs in project
126134
string[] guids = AssetDatabase.FindAssets("t:ScriptableObject");
127135
foreach (var guid in guids)
128136
{
129137
string path = AssetDatabase.GUIDToAssetPath(guid);
130138
var so = AssetDatabase.LoadAssetAtPath<ScriptableObject>(path);
131-
if (so is ISOEventBase) //
139+
if (so is ISOEventBase)
132140
{
133141
_allProjectEvents.Add(so);
134142
_masterResults[so] = new Dictionary<string, List<UsageDetail>>();
135-
if (!_expansionStates.ContainsKey(so)) _expansionStates[so] = true; // Expandido por defecto
143+
if (!_expansionStates.ContainsKey(so)) _expansionStates[so] = true;
136144
}
137145
}
138146

147+
// 2. Perform deep dependency scan
139148
string[] potentialAssets = AssetDatabase.FindAssets("t:Prefab t:Scene");
140149
foreach (var guid in potentialAssets)
141150
{
@@ -161,6 +170,7 @@ private void ScanPrefab(string path, ScriptableObject target)
161170

162171
private void ScanScene(string path, ScriptableObject target)
163172
{
173+
// Load scene additively and silently to inspect contents
164174
var tempScene = EditorSceneManager.OpenScene(path, OpenSceneMode.Additive);
165175
var allComponents = Resources.FindObjectsOfTypeAll<Component>().Where(c => c.gameObject.scene == tempScene);
166176
CheckComponents(path, allComponents, target);
@@ -172,6 +182,8 @@ private void CheckComponents(string assetPath, IEnumerable<Component> components
172182
foreach (var comp in components)
173183
{
174184
if (comp == null) continue;
185+
186+
// Iterate through all serialized properties to find the SO reference
175187
SerializedObject so = new SerializedObject(comp);
176188
SerializedProperty prop = so.GetIterator();
177189

0 commit comments

Comments
 (0)