Пример #1
0
        public static void RegisterObject(WindowObject obj)
        {
            if (WindowSystem.IsDebugWeakReferences() == false)
            {
                return;
            }
            if (Application.isPlaying == false)
            {
                return;
            }

            //if ((obj.GetWindow() is MW2.UI.EditorTools.Console.ConsoleScreen) == false/*obj.GetComponentsInParent<MW2.UI.EditorTools.Console.ConsoleScreen>(true).Length == 0*/) {

            //Debug.Log("ADD: " + obj.name + " :: " + obj.GetInstanceID());

            var item = WindowSystemResources.instance.registered.FirstOrDefault(x => x.instanceId == obj.GetInstanceID());

            if (item != null)
            {
                Debug.LogError("Object is already in list: " + item.name + " :: " + item.instanceId);
            }
            WindowSystemResources.instance.registered.Add(new ObjectEntity()
            {
                name = string.Format("{0} ({1})", obj.name, obj.GetInstanceID()), instanceId = obj.GetInstanceID(), reference = obj, window = obj.GetWindow()
            });
            WeakReferenceInfo.Register(obj);

            //}
        }
Пример #2
0
        public static void UnregisterObject(WindowObject obj)
        {
            if (WindowSystem.IsDebugWeakReferences() == false)
            {
                return;
            }
            if (Application.isPlaying == false)
            {
                return;
            }

            //if ((obj.GetWindow() is MW2.UI.EditorTools.Console.ConsoleScreen) == false) {

            //Debug.Log("DEL: " + obj.name + " :: " + obj.GetInstanceID());

            var item = WindowSystemResources.instance.registered.FirstOrDefault(x => x.instanceId == obj.GetInstanceID());

            if (item != null)
            {
                WindowSystemResources.instance.registered.RemoveAll(x => x.instanceId == obj.GetInstanceID());
            }
            else
            {
                Debug.LogWarning(string.Format("Trying to unregister reference that doesn't exists: {0} ({1})", obj.name, obj.GetInstanceID()), obj);
            }

            //}
        }