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:
2025-11-11 12:32:36 +00:00
parent fe2eb0a280
commit acf46c701e
46 changed files with 1057 additions and 225 deletions

View File

@@ -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();

View File

@@ -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()

View File

@@ -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>

View File

@@ -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)
{

View File

@@ -307,7 +307,7 @@ namespace UI.CardSystem.DragDrop
}
#endregion
protected override void OnDestroy()
{
base.OnDestroy();

View File

@@ -106,7 +106,7 @@ namespace UI.CardSystem.DragDrop
base.OnDragEndedVisual();
// Card-specific visual effects when dragging ends
}
protected override void OnDestroy()
{
base.OnDestroy();

View File

@@ -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;

View File

@@ -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)
{

View File

@@ -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()
{

View File

@@ -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)
{

View File

@@ -172,10 +172,8 @@ namespace UI
}
}
protected override void OnDestroy()
internal override void OnManagedDestroy()
{
base.OnDestroy();
// Unsubscribe from events
if (_uiPageController != null)
{

View File

@@ -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()
{