Exemple #1
0
        internal static void ReleaseInspector <T>(T inspector) where T : InspectorBase
        {
            if (lastActiveInspector == inspector)
            {
                lastActiveInspector = null;
            }

            bool wasActive = ActiveInspector == inspector;
            int  wasIdx    = Inspectors.IndexOf(inspector);

            Inspectors.Remove(inspector);
            inspector.OnReturnToPool();
            Pool <T> .Return(inspector);

            if (wasActive)
            {
                ActiveInspector = null;
                // Try focus another inspector, or close the window.
                if (lastActiveInspector != null)
                {
                    SetInspectorActive(lastActiveInspector);
                    lastActiveInspector = null;
                }
                else if (Inspectors.Any())
                {
                    int newIdx = Math.Min(Inspectors.Count - 1, Math.Max(0, wasIdx - 1));
                    SetInspectorActive(Inspectors[newIdx]);
                }
                else
                {
                    UIManager.SetPanelActive(UIManager.Panels.Inspector, false);
                }
            }
        }
Exemple #2
0
        public static void SetInspectorActive(InspectorBase inspector)
        {
            UnsetActiveInspector();

            ActiveInspector = inspector;
            inspector.OnSetActive();
        }
Exemple #3
0
 public static void UnsetActiveInspector()
 {
     if (ActiveInspector != null)
     {
         lastActiveInspector = ActiveInspector;
         ActiveInspector.OnSetInactive();
         ActiveInspector = null;
     }
 }
        public void OnSetInspectorTab(InspectorBase inspector)
        {
            Color      activeColor = new Color(0, 0.25f, 0, 1);
            ColorBlock colors      = inspector.m_tabButton.colors;

            colors.normalColor           = activeColor;
            colors.highlightedColor      = activeColor;
            inspector.m_tabButton.colors = colors;
        }
        /// <summary>
        /// Draws the ReorderableList.
        /// </summary>
        public static void DrawReorderableList(ref ReorderableList reorderableList, InspectorBase inspector, Array drawnObject, string serializedData,
                                               ReorderableList.HeaderCallbackDelegate drawHeaderCallback, ReorderableList.ElementCallbackDelegate drawElementCallback,
                                               ReorderableList.ReorderCallbackDelegate reorderCallback, ReorderableList.AddCallbackDelegate addCallback,
                                               ReorderableList.RemoveCallbackDelegate removeCallback, ReorderableList.SelectCallbackDelegate selectCallback,
                                               Action <int> drawSelectedElementCallback, string key, bool requireOne, bool indentList)
        {
            // Initialize the reorder list on first run.
            if (reorderableList == null)
            {
                var data = inspector.PropertyFromName(inspector.serializedObject, serializedData);
                reorderableList = new ReorderableList(inspector.serializedObject, data, (reorderCallback != null), true, !Application.isPlaying,
                                                      !Application.isPlaying && (!requireOne || (drawnObject != null && drawnObject.Length > 1)));
                reorderableList.drawHeaderCallback = (Rect rect) =>
                {
                    EditorGUI.LabelField(rect, "Name");
                };
                if (drawHeaderCallback != null)
                {
                    reorderableList.drawHeaderCallback = drawHeaderCallback;
                }
                reorderableList.drawElementCallback = drawElementCallback;
                if (reorderCallback != null)
                {
                    reorderableList.onReorderCallback = reorderCallback;
                }
                reorderableList.onAddCallback    = addCallback;
                reorderableList.onRemoveCallback = removeCallback;
                reorderableList.onSelectCallback = selectCallback;
                if (EditorPrefs.GetInt(key, -1) != -1)
                {
                    reorderableList.index = EditorPrefs.GetInt(key, -1);
                }
            }

            var listRect = GUILayoutUtility.GetRect(0, reorderableList.GetHeight());

            // Indent the list so it lines up with the rest of the content.
            if (indentList)
            {
                listRect.x    += InspectorUtility.IndentWidth;
                listRect.xMax -= InspectorUtility.IndentWidth;
            }
            reorderableList.DoList(listRect);
            if (reorderableList != null && reorderableList.index != -1)
            {
                if (drawnObject != null && reorderableList.index < drawnObject.Length)
                {
                    EditorGUI.indentLevel++;
                    drawSelectedElementCallback(reorderableList.index);
                    EditorGUI.indentLevel--;
                }
            }
        }
        public void UnsetInspectorTab()
        {
            if (m_activeInspector == null)
            {
                return;
            }

            m_activeInspector.SetInactive();

            OnUnsetInspectorTab();

            m_activeInspector = null;
        }
        public void SetInspectorTab(InspectorBase inspector)
        {
            MainMenu.Instance.SetPage(HomePage.Instance);

            if (m_activeInspector == inspector)
            {
                return;
            }

            UnsetInspectorTab();

            m_activeInspector = inspector;
            inspector.SetActive();

            OnSetInspectorTab(inspector);
        }
Exemple #8
0
        public void OnSetInspectorTab(InspectorBase inspector)
        {
            Color activeColor = new Color(0, 0.25f, 0, 1);

            inspector.m_tabButton.colors = RuntimeProvider.Instance.SetColorBlock(inspector.m_tabButton.colors, activeColor, activeColor);
        }