Skip to content

Commit f12fd90

Browse files
committed
Updated API
1 parent ae56ed5 commit f12fd90

File tree

7 files changed

+31
-28
lines changed

7 files changed

+31
-28
lines changed

Runtime/IPoolable.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Pool.cs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,20 @@ public void Populate(int count)
5151
public GameObject Get() =>
5252
GetInstance().gameObject;
5353

54-
public GameObject Get(Transform parent, bool spawnInWorldSpace)
54+
public GameObject Get(Transform parent)
5555
{
5656
var instance = GetInstance();
5757

58-
instance.transform.SetParent(parent, spawnInWorldSpace);
58+
instance.transform.SetParent(parent);
59+
60+
return instance.gameObject;
61+
}
62+
63+
public GameObject Get(Transform parent, bool worldPositionStays)
64+
{
65+
var instance = GetInstance();
66+
67+
instance.transform.SetParent(parent, worldPositionStays);
5968

6069
return instance.gameObject;
6170
}
@@ -69,35 +78,23 @@ public GameObject Get(Vector3 position, Quaternion rotation)
6978
return instance.gameObject;
7079
}
7180

72-
public GameObject Get(Vector3 position, Quaternion rotation, Transform parent, bool spawnInWorldSpace)
81+
public GameObject Get(Vector3 position, Quaternion rotation, Transform parent)
7382
{
7483
var instance = GetInstance();
7584
var instanceTransform = instance.transform;
7685

77-
instanceTransform.SetParent(parent, spawnInWorldSpace);
7886
instanceTransform.SetPositionAndRotation(position, rotation);
87+
instanceTransform.SetParent(parent);
7988

8089
return instance.gameObject;
8190
}
8291

83-
public T Get<T>() where T : Component =>
84-
Get().GetComponent<T>();
85-
86-
public T Get<T>(Transform parent, bool spawnInWorldSpace) where T : Component =>
87-
Get(parent, spawnInWorldSpace).GetComponent<T>();
88-
89-
public T Get<T>(Vector3 position, Quaternion rotation) where T : Component =>
90-
Get(position, rotation).GetComponent<T>();
91-
92-
public T Get<T>(Vector3 position, Quaternion rotation, Transform parent, bool spawnInWorldSpace) where T : Component =>
93-
Get(position, rotation, parent, spawnInWorldSpace).GetComponent<T>();
94-
9592
public void Release(GameObject instance)
9693
{
9794
var poolable = instance.GetComponent<Poolable>();
9895
_instances.Push(poolable);
9996

100-
instance.transform.SetParent(null, false);
97+
instance.transform.SetParent(null);
10198
instance.SetActive(false);
10299
poolable.OnRelease();
103100
}

Runtime/Pool.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/PoolExtensions.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,32 @@ public static void Populate(this GameObject prefab, int count) =>
1010
public static GameObject Get(this GameObject prefab) =>
1111
Pool.GetPrefabPool(prefab).Get();
1212

13-
public static GameObject Get(this GameObject prefab, Transform parent, bool spawnInWorldSpace) =>
14-
Pool.GetPrefabPool(prefab).Get(parent, spawnInWorldSpace);
13+
public static GameObject Get(this GameObject prefab, Transform parent) =>
14+
Pool.GetPrefabPool(prefab).Get(parent);
15+
16+
public static GameObject Get(this GameObject prefab, Transform parent, bool worldPositionStays) =>
17+
Pool.GetPrefabPool(prefab).Get(parent, worldPositionStays);
1518

1619
public static GameObject Get(this GameObject prefab, Vector3 position, Quaternion rotation) =>
1720
Pool.GetPrefabPool(prefab).Get(position, rotation);
1821

19-
public static GameObject Get(this GameObject prefab, Vector3 position, Quaternion rotation, Transform parent, bool spawnInWorldSpace) =>
20-
Pool.GetPrefabPool(prefab).Get(position, rotation, parent, spawnInWorldSpace);
22+
public static GameObject Get(this GameObject prefab, Vector3 position, Quaternion rotation, Transform parent) =>
23+
Pool.GetPrefabPool(prefab).Get(position, rotation, parent);
2124

2225
public static T Get<T>(this GameObject prefab) where T : Component =>
2326
prefab.Get().GetComponent<T>();
2427

28+
public static T Get<T>(this GameObject prefab, Transform parent) where T : Component =>
29+
prefab.Get(parent).GetComponent<T>();
30+
2531
public static T Get<T>(this GameObject prefab, Transform parent, bool spawnInWorldSpace) where T : Component =>
2632
prefab.Get(parent, spawnInWorldSpace).GetComponent<T>();
2733

2834
public static T Get<T>(this GameObject prefab, Vector3 position, Quaternion rotation) where T : Component =>
2935
prefab.Get(position, rotation).GetComponent<T>();
3036

31-
public static T Get<T>(this GameObject prefab, Vector3 position, Quaternion rotation, Transform parent, bool spawnInWorldSpace) where T : Component =>
32-
prefab.Get(position, rotation, parent, spawnInWorldSpace).GetComponent<T>();
37+
public static T Get<T>(this GameObject prefab, Vector3 position, Quaternion rotation, Transform parent) where T : Component =>
38+
prefab.Get(position, rotation, parent).GetComponent<T>();
3339

3440
public static void Release(this GameObject instance)
3541
{

Runtime/PoolExtensions.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/PoolInstaller.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Poolable.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)