summaryrefslogtreecommitdiff
path: root/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Misc.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-05-08 23:15:13 +0800
committerchai <chaifix@163.com>2021-05-08 23:15:13 +0800
commitd07e14add74e017b52ab2371efeea1aa4ea10ced (patch)
treeefd07869326e4c428f5bfe43fad0c2583d32a401 /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);
+ }
+ }
+ }
+}