Skip to content

Commit 9353170

Browse files
author
Miguel Cartier
committed
fix(ui-service): resolve Phase 1 critical bugs
- Fix delay timing bugs in PresenterDelayerBase (wrong delay, missing unit conversion) - Fix unit conversion in AnimationDelayer (remove incorrect * 1000 multiplication) - Fix null reference in UiService.GetOrLoadUiAsync - Fix DelayUiPresenterData<T> inheritance (wrong base class) All critical blocking bugs from the architecture evaluation are now resolved.
1 parent dcc4c1d commit 9353170

File tree

4 files changed

+36
-36
lines changed

4 files changed

+36
-36
lines changed

Runtime/DelayUiPresenter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ internal override void InternalClose(bool destroy)
6565
/// </remarks>
6666
/// <typeparam name="T">The type of data held by the presenter.</typeparam>
6767
[RequireComponent(typeof(PresenterDelayerBase))]
68-
public abstract class DelayUiPresenterData<T> : UiPresenter, IUiPresenterData where T : struct
68+
public abstract class DelayUiPresenterData<T> : UiPresenter<T> where T : struct
6969
{
7070
[SerializeField] private PresenterDelayerBase _delayer;
7171

Runtime/Delayers/AnimationDelayer.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ namespace GameLovers.UiService
1111
[RequireComponent(typeof(Animation))]
1212
public class AnimationDelayer : PresenterDelayerBase
1313
{
14-
[SerializeField] protected Animation _animation;
15-
[SerializeField] protected AnimationClip _introAnimationClip;
16-
[SerializeField] protected AnimationClip _outroAnimationClip;
14+
[SerializeField] protected Animation _animation;
15+
[SerializeField] protected AnimationClip _introAnimationClip;
16+
[SerializeField] protected AnimationClip _outroAnimationClip;
1717

18-
/// <inheritdoc />
19-
public override float OpenDelayInSeconds => _introAnimationClip.length * 1000;
18+
/// <inheritdoc />
19+
public override float OpenDelayInSeconds => _introAnimationClip.length;
2020

21-
/// <inheritdoc />
22-
public override float CloseDelayInSeconds => _outroAnimationClip.length * 1000;
21+
/// <inheritdoc />
22+
public override float CloseDelayInSeconds => _outroAnimationClip.length;
2323

2424
private void OnValidate()
2525
{

Runtime/Delayers/PresenterDelayerBase.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,33 +45,33 @@ protected virtual void OnOpenStarted() { }
4545
/// </summary>
4646
protected virtual void OnCloseStarted() { }
4747

48-
internal async Task OpenWithDelay(Action onOpenedCompleted)
49-
{
50-
OnOpenStarted();
48+
internal async Task OpenWithDelay(Action onOpenedCompleted)
49+
{
50+
OnOpenStarted();
5151

52-
CurrentDelayTask = Task.Delay(Mathf.RoundToInt(OpenDelayInSeconds));
52+
CurrentDelayTask = Task.Delay(Mathf.RoundToInt(OpenDelayInSeconds * 1000));
5353

54-
await CurrentDelayTask;
54+
await CurrentDelayTask;
5555

56-
if (gameObject != null)
57-
{
58-
onOpenedCompleted();
59-
}
56+
if (gameObject != null)
57+
{
58+
onOpenedCompleted();
6059
}
60+
}
6161

62-
internal async Task CloseWithDelay(Action onCloseCompleted)
63-
{
64-
OnCloseStarted();
62+
internal async Task CloseWithDelay(Action onCloseCompleted)
63+
{
64+
OnCloseStarted();
6565

66-
CurrentDelayTask = Task.Delay(Mathf.RoundToInt(OpenDelayInSeconds));
66+
CurrentDelayTask = Task.Delay(Mathf.RoundToInt(CloseDelayInSeconds * 1000));
6767

68-
await CurrentDelayTask;
68+
await CurrentDelayTask;
6969

70-
if (gameObject != null)
71-
{
72-
gameObject.SetActive(false);
73-
onCloseCompleted();
74-
}
70+
if (gameObject != null)
71+
{
72+
gameObject.SetActive(false);
73+
onCloseCompleted();
7574
}
7675
}
76+
}
7777
}

Runtime/UiService.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -354,18 +354,18 @@ private void OpenUi(Type type)
354354
_visibleUiList.Add(type);
355355
}
356356

357-
private async UniTask<UiPresenter> GetOrLoadUiAsync(Type type)
357+
private async UniTask<UiPresenter> GetOrLoadUiAsync(Type type)
358+
{
359+
if (!_uiPresenters.TryGetValue(type, out var ui))
358360
{
359-
if (!_uiPresenters.TryGetValue(type, out var ui))
360-
{
361-
OpenLoadingSpinner();
362-
await LoadUiAsync(type);
363-
CloseLoadingSpinner();
364-
}
365-
366-
return ui;
361+
OpenLoadingSpinner();
362+
ui = await LoadUiAsync(type);
363+
CloseLoadingSpinner();
367364
}
368365

366+
return ui;
367+
}
368+
369369
private void OpenLoadingSpinner()
370370
{
371371
if (_loadingSpinnerType == null)

0 commit comments

Comments
 (0)