Created
December 18, 2022 02:18
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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