Skip to content

Commit d8eb397

Browse files
committed
set parent on spawn
1 parent 9e0d2a2 commit d8eb397

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Assets/CustomTools/ObjectPooling/Scripts/ObjectPool/ObjectPooler.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private void Start()
5656

5757
}
5858

59-
public GameObject SpawnFromPool(PooledObjectType tag, Vector3 pos, Quaternion rot)
59+
public GameObject SpawnFromPool(PooledObjectType tag, Vector3 pos, Quaternion rot, GameObject parent = null)
6060
{
6161

6262
if (!PoolDictionary.ContainsKey(tag))
@@ -86,6 +86,11 @@ public GameObject SpawnFromPool(PooledObjectType tag, Vector3 pos, Quaternion ro
8686
objToSpawn = ExpandPool(tag, pos, rot);
8787
}
8888

89+
if (parent)
90+
{
91+
objToSpawn.transform.SetParent(parent.transform);
92+
}
93+
8994
return objToSpawn;
9095
}
9196

0 commit comments

Comments
 (0)