Ejemplo n.º 1
0
        public void OnEnable()
        {
#if UNITY_EDITOR
            UnityEditor.Undo.undoRedoPerformed += OnUndoRedoPerformed;
#endif
            // Populate item states
            DebugMenuManager dmm = DebugMenuManager.instance;
            for (int panelIdx = 0; panelIdx < dmm.panelCount; ++panelIdx)
            {
                DebugPanel panel = dmm.GetDebugPanel(panelIdx);
                for (int itemIdx = 0; itemIdx < panel.itemCount; ++itemIdx)
                {
                    DebugItem      item           = panel.GetDebugItem(itemIdx);
                    DebugItemState debugItemState = FindDebugItemState(item);
                    if (debugItemState == null)
                    {
                        debugItemState           = item.handler.CreateDebugItemState();
                        debugItemState.hideFlags = HideFlags.DontSave;
                        debugItemState.Initialize(item);
                        debugItemState.SetValue(item.GetValue());
                        AddDebugItemState(debugItemState);
                    }
                }
            }

            DebugMenuManager.instance.SetDebugMenuState(this);
        }
        public void ReInitializeDebugItemStates()
        {
            CleanUp();
            // Populate item states
            DebugMenuManager dmm = DebugMenuManager.instance;

            for (int panelIdx = 0; panelIdx < dmm.panelCount; ++panelIdx)
            {
                DebugPanel panel = dmm.GetDebugPanel(panelIdx);
                for (int itemIdx = 0; itemIdx < panel.itemCount; ++itemIdx)
                {
                    DebugItem      item           = panel.GetDebugItem(itemIdx);
                    DebugItemState debugItemState = FindDebugItemState(item);
                    if (debugItemState == null)
                    {
                        debugItemState = item.handler.CreateDebugItemState();
                        if (debugItemState != null)
                        {
                            debugItemState.hideFlags = HideFlags.DontSave;
                            debugItemState.Initialize(item);
                            debugItemState.SetValue(item.GetValue());
                            AddDebugItemState(debugItemState);
                        }
                        else
                        {
                            Debug.LogWarning(String.Format("DebugItemState for item {0} of type {1} is not provided.\nDid you implement CreateDebugItemState in your custom Handler?", item.name, item.type));
                        }
                    }
                }
            }

            UpdateAllDebugItems();
        }