Skip to content

Commit

Permalink
Fixed bug with Timed Destroy on release
Browse files Browse the repository at this point in the history
  • Loading branch information
tangx246 committed Jan 21, 2022
1 parent b54c509 commit 91566b4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions Assets/Scripts/GameObject/TimedDestroy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,24 @@ public class TimedDestroy : MonoBehaviour
public float maxLifeSeconds = 3f;
public bool releaseIntoGameObjectPooler = false;

IEnumerator Start()
void OnEnable()
{
StartCoroutine(StartDestroy());
}

private void OnDisable()
{
StopAllCoroutines();
}

private IEnumerator StartDestroy()
{
yield return new WaitForSeconds(maxLifeSeconds);
if (releaseIntoGameObjectPooler)
{
GameObjectPooler.instance.Release(gameObject);
} else
}
else
{
Destroy(gameObject);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.tangx246.unitytools",
"version": "0.0.44",
"version": "0.0.45",
"displayName": "Unity Tools",
"description": "A collection of various useful tools for Unity",
"author": {
Expand Down

0 comments on commit 91566b4

Please sign in to comment.