com.wallstop-studios.unity-helpers 2.0.0-rc51 → 2.0.0-rc53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,7 +48,7 @@
48
48
  {
49
49
  DeferredDisposalResult<T[]> result = await GetAllObjectsOfTypeInScene<T>(scenePath);
50
50
  return new DeferredDisposalResult<T>(
51
- result.Result.FirstOrDefault(),
51
+ result.result.FirstOrDefault(),
52
52
  result.DisposeAsync
53
53
  );
54
54
  }
@@ -5,15 +5,19 @@
5
5
 
6
6
  public sealed class DeferredDisposalResult<T>
7
7
  {
8
- public T Result { get; }
8
+ public readonly T result;
9
+
9
10
  private readonly Func<Task> _disposeAsync;
10
11
 
11
12
  public DeferredDisposalResult(T result, Func<Task> disposeAsync)
12
13
  {
13
- Result = result;
14
- _disposeAsync = disposeAsync;
14
+ this.result = result;
15
+ _disposeAsync = disposeAsync ?? throw new ArgumentNullException(nameof(disposeAsync));
15
16
  }
16
17
 
17
- public Task DisposeAsync() => _disposeAsync();
18
+ public async Task DisposeAsync()
19
+ {
20
+ await _disposeAsync();
21
+ }
18
22
  }
19
23
  }
@@ -26,7 +26,11 @@
26
26
 
27
27
  Type type = typeof(T);
28
28
  GameObject instance = new($"{type.Name}-Singleton", type);
29
- if (instance.TryGetComponent(out _instance) && _instance.Preserve)
29
+ if (
30
+ instance.TryGetComponent(out _instance)
31
+ && _instance.Preserve
32
+ && Application.isPlaying
33
+ )
30
34
  {
31
35
  DontDestroyOnLoad(instance);
32
36
  }
@@ -66,7 +66,7 @@
66
66
  Assert.IsTrue(task.IsCompletedSuccessfully, task.Exception?.ToString() ?? string.Empty);
67
67
 
68
68
  _disposalTasks.Add(task.Result.DisposeAsync);
69
- SpriteRenderer found = task.Result.Result;
69
+ SpriteRenderer found = task.Result.result;
70
70
  Assert.IsTrue(found != null);
71
71
  }
72
72
 
@@ -85,7 +85,7 @@
85
85
 
86
86
  Assert.IsTrue(task.IsCompletedSuccessfully, task.Exception?.ToString() ?? string.Empty);
87
87
  _disposalTasks.Add(task.Result.DisposeAsync);
88
- SpriteRenderer[] found = task.Result.Result;
88
+ SpriteRenderer[] found = task.Result.result;
89
89
  Assert.That(found, Has.Length.EqualTo(7));
90
90
  }
91
91
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.wallstop-studios.unity-helpers",
3
- "version": "2.0.0-rc51",
3
+ "version": "2.0.0-rc53",
4
4
  "displayName": "Unity Helpers",
5
5
  "description": "Various Unity Helper Library",
6
6
  "dependencies": {},