public static void Destroy(UObject obj) { if (obj is Transform) { throw new ArgumentException("Unable to destroy Transform", nameof(obj)); } if (!obj) { return; } if (Application.isPlaying) { UObject.Destroy(obj); } else { UObject.DestroyImmediate(obj); } }