Skip to content

Commit 1e4498f

Browse files
authored
Merge pull request #6 from ertanturan/Sprint4-Code-Simplification
recttransform fix
2 parents ecb1bac + cc58805 commit 1e4498f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Assets/CustomTools/ObjectPooling/Scripts/ObjectPooler.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ public GameObject SpawnFromPool(PooledObjectType pooledObjectType, Vector3 posit
6464

6565
IPooledObject iPooledObj = objToSpawn.GetComponent<IPooledObject>();
6666

67-
IObjectPoolInitializable iInitializable = objToSpawn.GetComponent<IObjectPoolInitializable>();
67+
IObjectPoolInitializable initializable = objToSpawn.GetComponent<IObjectPoolInitializable>();
6868

69-
if (args != null && iInitializable != null)
69+
if (args != null && initializable != null)
7070
{
71-
iInitializable.Init(this, args);
71+
initializable.Init(this, args);
7272
}
7373

7474

@@ -86,6 +86,13 @@ public GameObject SpawnFromPool(PooledObjectType pooledObjectType, Vector3 posit
8686
objToSpawn.transform.SetParent(parent);
8787
}
8888

89+
RectTransform rect = objToSpawn.GetComponent<RectTransform>();
90+
if (rect != null)
91+
{
92+
rect.anchoredPosition = Vector2.zero;
93+
}
94+
95+
8996
return objToSpawn;
9097
}
9198

0 commit comments

Comments
 (0)