Last life cycle refactor updates + add comprehensive documentation (#57)
Co-authored-by: Michal Pikulski <michal.a.pikulski@gmail.com> Reviewed-on: #57
This commit is contained in:
@@ -93,10 +93,8 @@ public class AppSwitcher : UIPage
|
||||
);
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
internal override void OnManagedDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
|
||||
// Clean up tweens
|
||||
slideInTween?.Stop();
|
||||
slideOutTween?.Stop();
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace UI.CardSystem
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
internal override void OnManagedDestroy()
|
||||
{
|
||||
// Unsubscribe from CardSystemManager
|
||||
if (CardSystemManager.Instance != null)
|
||||
@@ -181,9 +181,6 @@ namespace UI.CardSystem
|
||||
|
||||
// Clean up active cards
|
||||
CleanupActiveCards();
|
||||
|
||||
// Call base implementation
|
||||
base.OnDestroy();
|
||||
}
|
||||
|
||||
private void OnExitButtonClicked()
|
||||
|
||||
@@ -70,16 +70,13 @@ namespace UI.CardSystem
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
internal override void OnManagedDestroy()
|
||||
{
|
||||
// Unsubscribe from CardSystemManager events to prevent memory leaks
|
||||
if (CardSystemManager.Instance != null)
|
||||
{
|
||||
CardSystemManager.Instance.OnBoosterCountChanged -= OnBoosterCountChanged;
|
||||
}
|
||||
|
||||
// Call base implementation
|
||||
base.OnDestroy();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -76,10 +76,8 @@ namespace UI.CardSystem
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
internal override void OnManagedDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
|
||||
// Unsubscribe from dismiss button
|
||||
if (_dismissButton != null)
|
||||
{
|
||||
|
||||
@@ -307,7 +307,7 @@ namespace UI.CardSystem.DragDrop
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace UI.CardSystem.DragDrop
|
||||
base.OnDragEndedVisual();
|
||||
// Card-specific visual effects when dragging ends
|
||||
}
|
||||
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
|
||||
@@ -15,9 +15,6 @@ namespace UI.Core
|
||||
[Header("Page Settings")]
|
||||
public string PageName;
|
||||
|
||||
// UI pages load after UI infrastructure (UIPageController is priority 50)
|
||||
public override int ManagedAwakePriority => 200;
|
||||
|
||||
// Events using System.Action instead of UnityEvents
|
||||
public event Action OnTransitionInStarted;
|
||||
public event Action OnTransitionInCompleted;
|
||||
|
||||
@@ -37,8 +37,6 @@ namespace UI.Core
|
||||
private PlayerInput _playerInput;
|
||||
private InputAction _cancelAction;
|
||||
|
||||
public override int ManagedAwakePriority => 50; // UI infrastructure
|
||||
|
||||
internal override void OnManagedAwake()
|
||||
{
|
||||
// Set instance immediately (early initialization)
|
||||
@@ -50,10 +48,8 @@ namespace UI.Core
|
||||
Logging.Debug("[UIPageController] Initialized");
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
internal override void OnManagedDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
|
||||
// Clean up cached instances
|
||||
foreach (var cachedPage in _prefabInstanceCache.Values)
|
||||
{
|
||||
|
||||
@@ -52,9 +52,6 @@ namespace UI
|
||||
/// Singleton instance of the LoadingScreenController. No longer creates an instance if one doesn't exist.
|
||||
/// </summary>
|
||||
public static LoadingScreenController Instance => _instance;
|
||||
|
||||
// ManagedBehaviour configuration
|
||||
public override int ManagedAwakePriority => 45; // UI infrastructure, before UIPageController
|
||||
|
||||
internal override void OnManagedAwake()
|
||||
{
|
||||
|
||||
@@ -27,9 +27,6 @@ namespace UI
|
||||
[SerializeField] private UnityEngine.UI.Button devOptionsButton;
|
||||
[SerializeField] private GameObject mainOptionsContainer;
|
||||
[SerializeField] private GameObject devOptionsContainer;
|
||||
|
||||
// After UIPageController (50)
|
||||
public override int ManagedAwakePriority => 55;
|
||||
|
||||
internal override void OnManagedAwake()
|
||||
{
|
||||
@@ -76,10 +73,8 @@ namespace UI
|
||||
// This only fires once for DontDestroyOnLoad objects, so we handle scene loads in OnManagedAwake
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
internal override void OnManagedDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
|
||||
// Unsubscribe when destroyed
|
||||
if (SceneManagerService.Instance != null)
|
||||
{
|
||||
|
||||
@@ -172,10 +172,8 @@ namespace UI
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
internal override void OnManagedDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
|
||||
// Unsubscribe from events
|
||||
if (_uiPageController != null)
|
||||
{
|
||||
|
||||
@@ -30,7 +30,6 @@ namespace UI.Tutorial
|
||||
private bool _canAcceptInput;
|
||||
private Coroutine _waitLoopCoroutine;
|
||||
|
||||
public override int ManagedAwakePriority => 200; // Tutorial runs late, after other systems
|
||||
|
||||
internal override void OnManagedStart()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user