summaryrefslogtreecommitdiff
path: root/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Misc.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-10-08 09:50:33 +0800
committerchai <chaifix@163.com>2020-10-08 09:50:33 +0800
commit00dae1bd426d892dff73a50f1c505afd1ac00a90 (patch)
tree5d75f8495406f5b8dd01595e3dd9216887996a34 /Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Misc.cs
+init
Diffstat (limited to 'Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Misc.cs')
-rw-r--r--Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Misc.cs44
1 files changed, 44 insertions, 0 deletions
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Misc.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Misc.cs
new file mode 100644
index 0000000..66e2892
--- /dev/null
+++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Misc.cs
@@ -0,0 +1,44 @@
+namespace UnityEngine.UI
+{
+ /// <summary>
+ /// Helper class containing generic functions used throughout the UI library.
+ /// </summary>
+
+ internal static class Misc
+ {
+ /// <summary>
+ /// Destroy the specified object, immediately if in edit mode.
+ /// </summary>
+
+ static public void Destroy(UnityEngine.Object obj)
+ {
+ if (obj != null)
+ {
+ if (Application.isPlaying)
+ {
+ if (obj is GameObject)
+ {
+ GameObject go = obj as GameObject;
+ go.transform.parent = null;
+ }
+
+ Object.Destroy(obj);
+ }
+ else Object.DestroyImmediate(obj);
+ }
+ }
+
+ /// <summary>
+ /// Destroy the specified object immediately, unless not in the editor, in which case the regular Destroy is used instead.
+ /// </summary>
+
+ static public void DestroyImmediate(Object obj)
+ {
+ if (obj != null)
+ {
+ if (Application.isEditor) Object.DestroyImmediate(obj);
+ else Object.Destroy(obj);
+ }
+ }
+ }
+}