//Destroy Faster Than Simple Destroy (Works in Editor too)
 public static void DestroyImmediate(Object p_object, bool p_onlyDestroyInEditor = false)
 {
     if (p_object != null)
     {
         DestroyUtils.Destroy(p_object, p_onlyDestroyInEditor);
         MarkedToDestroy v_mark = MarkedToDestroy.GetMark(p_object);
         if (v_mark != null)
         {
             v_mark.DestroyOnStart = true;
         }
     }
 }
Beispiel #2
0
        public static void RemoveMark(Object p_object)
        {
            MarkedToDestroy v_mark = GetMark(p_object);

            if (v_mark != null && v_mark.Target == p_object)
            {
                if (v_mark.Target != null && v_mark.Target.name != null)
                {
                    v_mark.Target.name = v_mark.Target.name.Replace("(MarkedToDestroy)", "");
                    v_mark.ReverseCheckActivation();
                }
                v_mark.Target        = null;
                v_mark.TimeToDestroy = 0;
            }
        }
Beispiel #3
0
        public static MarkedToDestroy GetMark(Object p_object)
        {
            MarkedToDestroy v_mark = null;

            if (p_object != null)
            {
                foreach (MarkedToDestroy v_marked in _markedToDestroyInstances)
                {
                    if (v_marked != null && v_marked.Target == p_object)
                    {
                        v_mark = v_marked;
                        break;
                    }
                }
            }
            return(v_mark);
        }
 //Delayed Destroy in Editor
 public static void Destroy(Object p_object, float p_time, bool p_ignoreTimeScale = true, bool p_onlyDestroyInEditor = false)
 {
     if (p_object != null)
     {
         MarkedToDestroy v_mark = MarkedToDestroy.GetMark(p_object);
         if (v_mark == null)
         {
             GameObject v_newObject = new GameObject();
             v_mark = v_newObject.AddComponent <MarkedToDestroy>();
             v_newObject.transform.SetAsFirstSibling();
         }
         v_mark.Target = p_object;
         v_mark.OnlyDestroyInEditor = p_onlyDestroyInEditor;
         v_mark.DestroyOnStart      = false;
         v_mark.TimeToDestroy       = p_time;
         v_mark.IgnoreTimeScale     = p_ignoreTimeScale;
     }
 }