1
- /** Simple Lifecycle Manager for Unity
1
+ /** CancellationToken based Lifecycle Manager for Unity
2
2
** (c) 2024 github.com/sator-imaging
3
3
** Licensed under the MIT License
4
4
5
- This library helps managing MonoBehaviour lifetime by CancellationToken introduced in Unity 2022.
5
+ This library helps managing MonoBehaviour lifetime by ` CancellationToken` introduced in Unity 2022.
6
6
Not only that but also has an ability to manage "Update" actions ordered and efficiently.
7
7
8
8
And also! library provides missing `destroyCancellationToken` feature for Unity 2021 LTS!!
9
9
10
10
**Feature Highlights**
11
- - [Class Instance Lifetime Management](#object-lifetime-management)
11
+ - [Object Lifetime Management](#object-lifetime-management)
12
12
- [Update Function Manager](#update-function-manager)
13
13
- Designed to address consideration written in the following article
14
14
- https://blog.unity.com/engine-platform/10000-update-calls
@@ -101,7 +101,7 @@ Note that C# class instances and GameObjects destruction order is stable whereas
101
101
when scene is unloaded otherwise destroyed based on binding order.
102
102
103
103
> [!NOTE]
104
- > To make destruction order stable, extension method automatically mark lifetime bound GameObjects as
104
+ > To make destruction order stable, extension method automatically marks lifetime bound GameObjects as
105
105
> `DontDestroyOnLoad`.
106
106
107
107
@@ -512,12 +512,12 @@ public void Clear()
512
512
/// Do nothing when null action specified.
513
513
/// </remarks>
514
514
/// <returns>
515
- /// Returns received action instance as-is. It is null when null is passed.
516
515
/// <para>
516
+ /// Returns received action instance as-is. It is null when null is passed.
517
+ /// </para>
517
518
/// > [!NOTE]
518
519
/// > `Add(instance.Method)` will create new Action instance call by call implicitly.
519
- /// > If try to remove action later, it requires to specify exactly same instance so need to keep returned instance.
520
- /// </para>
520
+ /// > If plan to remove action later, removing requires exactly same instance so need to keep returned one.
521
521
/// </returns>
522
522
public Action Add ( Action act )
523
523
{
@@ -540,11 +540,11 @@ public Action Add(Action act)
540
540
}
541
541
542
542
/// <remarks>
543
- /// Do nothing when null action specified.
544
543
/// <para>
544
+ /// Do nothing when null action specified.
545
+ /// </para>
545
546
/// > [!WARNING]
546
547
/// > Item order will be changed. See file header document for details.
547
- /// </para>
548
548
/// </remarks>
549
549
public void Remove ( Action act )
550
550
{
@@ -611,12 +611,12 @@ internal SceneLifetime(Scene scene)
611
611
{
612
612
if ( _sceneToLifetime . ContainsKey ( scene ) )
613
613
{
614
- throw new InvalidOperationException (
614
+ throw new ArgumentException (
615
615
LOG_PREFIX + "scene lifetime has already been created. use `Get` method instead: " + scene ) ;
616
616
}
617
617
618
618
if ( ! scene . IsValid ( ) )
619
- throw new NotSupportedException ( LOG_PREFIX + "scene is invalid: " + scene ) ;
619
+ throw new ArgumentException ( LOG_PREFIX + "scene is invalid: " + scene ) ;
620
620
621
621
_sceneInfo = "BuildIndex:" + scene . buildIndex + " " + scene . name ;
622
622
_sceneToLifetime . Add ( scene , this ) ;
@@ -745,7 +745,7 @@ public static class LifetimeExtensions
745
745
/// <summary>
746
746
/// Arguments: (obj, token, ticket, ownerOrNull)
747
747
/// <para>
748
- /// Invoked before object bound to token.
748
+ /// Invoked when object bound to token or lifetime owner .
749
749
/// </para>
750
750
/// </summary>
751
751
public static Action < object , CancellationToken , CancellationTokenRegistration , object ? > ? DebuggerAction
0 commit comments