Skip to content

Commit

Permalink
Change set active after set parent and set transform
Browse files Browse the repository at this point in the history
  • Loading branch information
scriptsengineer committed Oct 24, 2021
1 parent a734719 commit 732c8eb
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Runtime/Scripts/Pool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,41 @@ public void Setup(PoolSettings settings, GameObject prefab)

public GameObject Instantiate()
{
return Dequeue();
GameObject gameObject = Dequeue();
gameObject.SetActive(true);
return gameObject;
}

public GameObject Instantiate(Vector3 position, Quaternion rotation)
{
GameObject gameObject = Instantiate();
GameObject gameObject = Dequeue();
gameObject.transform.SetPositionAndRotation(position, rotation);
gameObject.SetActive(true);
return gameObject;
}

public GameObject Instantiate(Transform parent)
{
GameObject gameObject = Instantiate();
GameObject gameObject = Dequeue();
gameObject.transform.SetParent(parent);
gameObject.SetActive(true);
return gameObject;
}

public GameObject Instantiate(Transform parent, bool instantiateInWorldSpace)
{
GameObject gameObject = Instantiate();
GameObject gameObject = Dequeue();
gameObject.transform.SetParent(parent, instantiateInWorldSpace);
gameObject.SetActive(true);
return gameObject;
}

public GameObject Instantiate(Vector3 position, Quaternion rotation, Transform parent)
{
GameObject gameObject = Instantiate(position, rotation);
GameObject gameObject = Dequeue();
gameObject.transform.SetPositionAndRotation(position, rotation);
gameObject.transform.SetParent(parent);
gameObject.SetActive(true);
return gameObject;
}

Expand Down Expand Up @@ -129,7 +136,6 @@ private GameObject Dequeue()
obj = Object.Instantiate(prefab);
}
OnPoolerEnable(obj);
obj.SetActive(true);
OnDequeue?.Invoke(this,obj);

// NOTE This exists for cases that have calls in two instantaneous locations and only one has pooldata as a reference.
Expand Down

0 comments on commit 732c8eb

Please sign in to comment.