blob: 66e2892d0f556f419c91fdab0e2382a86726f31c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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);
}
}
}
}
|