com.amanotes.prefabpool 2.0.2 → 2.0.3

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.0.3] - 2026-09-24
4
+
5
+ ### Added
6
+ - `IPrefabPool.TryReturn` / `PoolGroup.TryReturn` — returns whether the instance was in the checkout ledger (`Return` remains a silent no-op when unknown).
7
+
3
8
  ## [2.0.2] - 2026-09-14
4
9
 
5
10
  ### Fixed
@@ -1,6 +1,6 @@
1
1
  # PrefabPool API Reference
2
2
 
3
- **Package:** `com.amanotes.prefabpool` | **Version:** 2.0.2 | **Namespace:** `Amanotes.Core`
3
+ **Package:** `com.amanotes.prefabpool` | **Version:** 2.0.3 | **Namespace:** `Amanotes.Core`
4
4
 
5
5
  Generic object pooling system to eliminate garbage collection spikes from frequent instantiation/destruction.
6
6
 
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # PrefabPool
2
2
 
3
3
  **Package:** `com.amanotes.prefabpool`
4
- **Version:** 2.0.2
4
+ **Version:** 2.0.3
5
5
 
6
6
  Generic object pooling system for Unity with lifecycle callbacks and material pooling support.
7
7
 
@@ -30,7 +30,7 @@ Add the package to your Unity project via `Packages/manifest.json`:
30
30
  ```json
31
31
  {
32
32
  "dependencies": {
33
- "com.amanotes.prefabpool": "2.0.2"
33
+ "com.amanotes.prefabpool": "2.0.3"
34
34
  },
35
35
  "scopedRegistries": [
36
36
  {
@@ -196,6 +196,12 @@ namespace Amanotes.Core
196
196
  {
197
197
  _prefabPool?.Return(this, gameObject);
198
198
  }
199
+
200
+ public bool TryReturn(GameObject gameObject)
201
+ {
202
+ if (_prefabPool == null || gameObject == null) return false;
203
+ return _prefabPool.TryReturn(this, gameObject);
204
+ }
199
205
 
200
206
  public Transform SpawnParent => _spawnParent;
201
207
  }
@@ -207,6 +213,8 @@ namespace Amanotes.Core
207
213
  void SetSpawnParent(string groupId, Transform spawnParent);
208
214
  GameObject Get(PoolGroup group, string prefabId, Vector3 localPosition = default, Transform customParent = null);
209
215
  void Return(PoolGroup group, GameObject gameObject);
216
+ /// <summary>Returns false when the instance was not checked out from this pool (silent no-op in <see cref="Return"/>).</summary>
217
+ bool TryReturn(PoolGroup group, GameObject gameObject);
210
218
  IEnumerator Initialize();
211
219
  /// <summary>
212
220
  /// Marks the pool as shut down so all subsequent Get/Return calls no-op safely.
@@ -418,15 +426,21 @@ namespace Amanotes.Core
418
426
 
419
427
  public void Return(PoolGroup group, GameObject go)
420
428
  {
421
- if (_isDestroyed || group == null || go == null) return;
422
-
429
+ TryReturn(group, go);
430
+ }
431
+
432
+ public bool TryReturn(PoolGroup group, GameObject go)
433
+ {
434
+ if (_isDestroyed || group == null || go == null) return false;
435
+
423
436
  var instanceId = UnityObjectIdentity.GetId(go);
424
- if (_instanceTypeMap.TryGetValue(instanceId, out var entry))
425
- {
426
- entry.Return(go, transform);
427
- _instanceTypeMap.Remove(instanceId);
428
- _liveInstances.Remove(instanceId);
429
- }
437
+ if (!_instanceTypeMap.TryGetValue(instanceId, out var entry))
438
+ return false;
439
+
440
+ entry.Return(go, transform);
441
+ _instanceTypeMap.Remove(instanceId);
442
+ _liveInstances.Remove(instanceId);
443
+ return true;
430
444
  }
431
445
 
432
446
  private void PurgeStaleInstanceMap()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.amanotes.prefabpool",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "displayName": "[Ama] Prefab Pool",
5
5
  "description": "Generic object pooling system for Unity",
6
6
  "unity": "2022.3",