Skip to content

Commit 16877a8

Browse files
author
Miguel Cartier
committed
refactor: Remove the loading spinner from the UiService
1 parent 02a9dc0 commit 16877a8

File tree

5 files changed

+5
-141
lines changed

5 files changed

+5
-141
lines changed

Editor/UiConfigsEditor.cs

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ public override void OnInspectorGUI()
9393
{
9494
serializedObject.Update();
9595

96-
LoadingSpinnerLayout();
97-
9896
EditorGUILayout.Space();
9997
EditorGUILayout.HelpBox(_uiConfigGuiContent.tooltip, MessageType.Info);
10098
_configList.DoLayoutList();
@@ -111,31 +109,6 @@ public override void OnInspectorGUI()
111109
}
112110
}
113111

114-
private void LoadingSpinnerLayout()
115-
{
116-
var uiPresentersNames = new List<string> { "<None>" };
117-
var uiPresentersAssemblyNames = new List<string> { "<None>" };
118-
119-
foreach (var uiConfig in _scriptableObject.Configs)
120-
{
121-
uiPresentersNames.Add(uiConfig.UiType.Name);
122-
uiPresentersAssemblyNames.Add(uiConfig.UiType.AssemblyQualifiedName);
123-
}
124-
125-
var selectedIndex = 0;
126-
if (_scriptableObject.LoadingSpinnerType != null)
127-
{
128-
selectedIndex = uiPresentersAssemblyNames.FindIndex(uiPresenterName =>
129-
_scriptableObject.LoadingSpinnerTypeString ==
130-
uiPresenterName);
131-
selectedIndex = Math.Max(selectedIndex, 0);
132-
}
133-
134-
selectedIndex = EditorGUILayout.Popup("Loading Spinner Presenter", selectedIndex, uiPresentersNames.ToArray());
135-
_scriptableObject.LoadingSpinnerTypeString =
136-
selectedIndex == 0 ? null : uiPresentersAssemblyNames[selectedIndex];
137-
}
138-
139112
private void InitConfigValues()
140113
{
141114
var assetList = GetAssetList();
@@ -190,14 +163,15 @@ private void InitConfigValues()
190163
Layer = sortingOrder < 0 ? 0 : sortingOrder,
191164
UiType = type,
192165
LoadSynchronously = Attribute.IsDefined(type, typeof(LoadSynchronouslyAttribute))
193-
194166
};
195167

168+
// Always add to dropdown arrays (for both new and existing configs)
169+
uiConfigsAddress.Add(config.AddressableAddress);
170+
_uiConfigsType.Add(config.UiType.AssemblyQualifiedName);
171+
172+
// Preserve custom layer value for existing configs
196173
if (indexMatch > -1)
197174
{
198-
uiConfigsAddress.Add(config.AddressableAddress);
199-
_uiConfigsType.Add(config.UiType.AssemblyQualifiedName);
200-
201175
config.Layer = sortingOrder < 0 ? configsCache[indexMatch].Layer : config.Layer;
202176
}
203177

Editor/UiLayerVisualizerWindow.cs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public class UiLayerVisualizerWindow : EditorWindow
1515
{
1616
private Vector2 _scrollPosition;
1717
private UiConfigs _selectedConfigs;
18-
private bool _showLoadingSpinner = true;
1918
private bool _showLayers = true;
2019
private string _searchFilter = "";
2120

@@ -46,11 +45,6 @@ private void OnGUI()
4645

4746
_scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition);
4847

49-
if (_showLoadingSpinner)
50-
{
51-
DrawLoadingSpinner();
52-
}
53-
5448
if (_showLayers)
5549
{
5650
DrawLayerHierarchy();
@@ -90,7 +84,6 @@ private void DrawToolbar()
9084
{
9185
EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
9286

93-
_showLoadingSpinner = GUILayout.Toggle(_showLoadingSpinner, "Loading Spinner", EditorStyles.toolbarButton);
9487
_showLayers = GUILayout.Toggle(_showLayers, "Layer Hierarchy", EditorStyles.toolbarButton);
9588

9689
GUILayout.FlexibleSpace();
@@ -111,26 +104,6 @@ private void DrawNoConfigsMessage()
111104
}
112105
}
113106

114-
private void DrawLoadingSpinner()
115-
{
116-
EditorGUILayout.LabelField("Loading Spinner", EditorStyles.boldLabel);
117-
EditorGUI.indentLevel++;
118-
119-
var spinnerType = _selectedConfigs.LoadingSpinnerType;
120-
if (spinnerType != null)
121-
{
122-
EditorGUILayout.LabelField("Type:", spinnerType.Name);
123-
EditorGUILayout.LabelField("Full Name:", spinnerType.FullName);
124-
}
125-
else
126-
{
127-
EditorGUILayout.HelpBox("No loading spinner configured", MessageType.Info);
128-
}
129-
130-
EditorGUI.indentLevel--;
131-
EditorGUILayout.Space(10);
132-
}
133-
134107
private void DrawLayerHierarchy()
135108
{
136109
EditorGUILayout.LabelField("Layer Hierarchy", EditorStyles.boldLabel);

README.md

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ Visualize your UI configuration and layer organization before entering play mode
273273
- **Layer Organization** - See all UIs grouped by layer number
274274
- **Color-coded Layers** - Each layer has a unique color for easy identification
275275
- **Configuration Overview** - View UiConfigs structure without playing
276-
- **Loading Spinner Info** - See which presenter is set as loading spinner
277276
- **Search & Filter** - Find specific UIs quickly
278277
- **Statistics** - Total UIs, layer counts, sync vs async loading
279278
- **Synchronous Loading Indicators** - Clearly marks UIs that load synchronously
@@ -1104,33 +1103,6 @@ async void OnLevelComplete()
11041103

11051104
---
11061105

1107-
#### Issue: Loading Spinner Not Appearing
1108-
1109-
**Symptoms**: Long loads show no feedback to user
1110-
1111-
**Solutions**:
1112-
1113-
1. **Set Loading Spinner in UiConfigs**
1114-
```csharp
1115-
// In UiConfigs ScriptableObject
1116-
// Set "Loading Spinner Type" field to your spinner presenter type
1117-
```
1118-
1119-
2. **Ensure Spinner is Preloaded**
1120-
```csharp
1121-
// Loading spinner is auto-loaded on Init
1122-
// Make sure Init is called before any UI operations
1123-
_uiService.Init(_uiConfigs);
1124-
```
1125-
1126-
3. **Check Layer Order**
1127-
```csharp
1128-
// Loading spinner should be on highest layer
1129-
// e.g., Layer 999 so it appears above everything
1130-
```
1131-
1132-
---
1133-
11341106
#### Issue: UI Flickers or Appears Briefly Before Opening
11351107

11361108
**Cause**: UI GameObject is active during initialization

Runtime/UiConfigs.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,11 @@ public struct UiConfig
2525
[CreateAssetMenu(fileName = "UiConfigs", menuName = "ScriptableObjects/Configs/UiConfigs")]
2626
public class UiConfigs : ScriptableObject//, IConfigsContainer<UiConfig>
2727
{
28-
[SerializeField] private string _loadingSpinnerType;
2928
[SerializeField]
3029
private List<UiConfigSerializable> _configs = new List<UiConfigSerializable>();
3130
[SerializeField]
3231
private List<UiSetConfigSerializable> _sets = new List<UiSetConfigSerializable>();
3332

34-
/// <summary>
35-
/// Gets or sets the type of the loading spinner
36-
/// </summary>
37-
public Type LoadingSpinnerType
38-
{
39-
get => String.IsNullOrEmpty(_loadingSpinnerType) ? null : Type.GetType(_loadingSpinnerType);
40-
set => _loadingSpinnerType = value?.GetType().AssemblyQualifiedName;
41-
}
42-
43-
/// <summary>
44-
/// Gets or sets the type of the loading spinner as a string
45-
/// </summary>
46-
public string LoadingSpinnerTypeString
47-
{
48-
get => _loadingSpinnerType;
49-
set => _loadingSpinnerType = value;
50-
}
51-
5233
/// <summary>
5334
/// Gets or sets the list of UI configurations
5435
/// </summary>

Runtime/UiService.cs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public class UiService : IUiServiceInit
3737
private readonly IReadOnlyDictionary<int, UiSetConfig> _uiSetsReadOnly;
3838
private readonly IReadOnlyList<Type> _visiblePresentersReadOnly;
3939

40-
private Type _loadingSpinnerType;
4140
private Transform _uiParent;
4241
private bool _disposed;
4342

@@ -117,22 +116,9 @@ public void Init(UiConfigs configs)
117116
}
118117

119118
_uiParent = new GameObject("Ui").transform;
120-
_loadingSpinnerType = configs.LoadingSpinnerType;
121119

122120
_uiParent.gameObject.AddComponent<UiServiceMonoComponent>();
123121
Object.DontDestroyOnLoad(_uiParent.gameObject);
124-
125-
if (_loadingSpinnerType != null)
126-
{
127-
if (!_uiConfigs.ContainsKey(_loadingSpinnerType))
128-
{
129-
Debug.LogError($"Loading spinner type '{_loadingSpinnerType.Name}' is set but has no corresponding UiConfig. Loading spinner will not work.");
130-
}
131-
else
132-
{
133-
LoadUiAsync(_loadingSpinnerType).Forget();
134-
}
135-
}
136122
}
137123

138124
/// <inheritdoc />
@@ -438,34 +424,12 @@ private async UniTask<UiPresenter> GetOrLoadUiAsync(Type type, CancellationToken
438424
{
439425
if (!_uiPresenters.TryGetValue(type, out var ui))
440426
{
441-
OpenLoadingSpinner();
442427
ui = await LoadUiAsync(type, false, cancellationToken);
443-
CloseLoadingSpinner();
444428
}
445429

446430
return ui;
447431
}
448432

449-
private void OpenLoadingSpinner()
450-
{
451-
if (_loadingSpinnerType == null)
452-
{
453-
return;
454-
}
455-
456-
OpenUi(_loadingSpinnerType);
457-
}
458-
459-
private void CloseLoadingSpinner()
460-
{
461-
if (_loadingSpinnerType == null)
462-
{
463-
return;
464-
}
465-
466-
CloseUi(_loadingSpinnerType);
467-
}
468-
469433
/// <summary>
470434
/// Disposes of the UI service, cleaning up all resources and unsubscribing from events.
471435
/// </summary>

0 commit comments

Comments
 (0)