Skip to content

Instantly share code, notes, and snippets.

@gekidoslair
Created December 18, 2022 02:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gekidoslair/c2ea90baf318ca00d881a34c582d6d7e to your computer and use it in GitHub Desktop.
Save gekidoslair/c2ea90baf318ca00d881a34c582d6d7e to your computer and use it in GitHub Desktop.
Destroys this object if we're in play mode. Useful for debug stuff that you don't want in the actual game
using UnityEngine;
namespace PixelWizards.Utilities
{
/// <summary>
/// Destroys this object if we're in play mode.
/// Useful for debug stuff that you don't want in the actual game
/// </summary>
public class DestroyOnPlay : MonoBehaviour
{
private void OnEnable()
{
if (Application.isPlaying)
{
Destroy(this.gameObject);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment