예제 #1
0
 void typePoolsGUI(DTInspectorNode node)
 {
     foreach (var kv in Target.TypePools)
     {
         showBar(kv.Value);
     }
 }
예제 #2
0
 public virtual DTInspectorNode Add(DTInspectorNode node)
 {
     if (node != null)
     {
         Items.Add(node);
         node.Index  = Items.IndexOf(node);
         node.Parent = this;
         node.Level  = node.Parent.Level + 1;
     }
     return(node);
 }
예제 #3
0
        public override DTInspectorNode Add(DTInspectorNode node)
        {
            node = base.Add(node);
            var grp = node as DTGroupNode;

            if (grp != null && _serializedObject != null && _serializedObject.targetObject != null)
            {
                grp.mState.value = DTPersistentState.GetBool(_serializedObject.targetObject.GetInstanceID().ToString() + grp.Path, grp.mState.value);
            }

            return(node);
        }
예제 #4
0
 public void Delete()
 {
     foreach (var it in Items)
     {
         it.Delete();
     }
     if (Parent)
     {
         Parent.Items.Remove(this);
         Parent.Sort(); // to reset Index
     }
     Parent = null;
 }
예제 #5
0
        /// <summary>
        /// Search for a node at a specific path
        /// </summary>
        /// <typeparam name="T">Type of the node in question</typeparam>
        /// <param name="name">Path and Name of the node in question</param>
        /// <param name="node">The search result or null</param>
        /// <returns>true if found</returns>
        public bool FindNodeAt <T>(string pathAndName, out T node) where T : DTInspectorNode
        {
            var p = pathAndName.Split('/');

            node = null;
            DTInspectorNode N = this;

            for (int i = 0; i < p.Length; i++)
            {
                N = N[p[i]];
                if (N == null)
                {
                    return(false);
                }
            }
            node = N as T;
            return(node != null);
        }
예제 #6
0
        public virtual void RenderAction(DTInspectorNode node, ActionAttribute action, System.Object editorObject, System.Object targetObject)
        {
            switch (action.Action)
            {
            case ActionAttribute.ActionEnum.ShowInfo:
                EditorGUILayout.HelpBox(action.ActionData as string, MessageType.Info);
                return;

            case ActionAttribute.ActionEnum.ShowWarning:
                EditorGUILayout.HelpBox(action.ActionData as string, MessageType.Warning);
                return;

            case ActionAttribute.ActionEnum.ShowError:
                EditorGUILayout.HelpBox(action.ActionData as string, MessageType.Error);
                return;

            case ActionAttribute.ActionEnum.Callback:
                action.Callback(editorObject);
                return;
            }
        }
예제 #7
0
        /// <summary>
        /// Renders the node tree and process rendering attributes
        /// </summary>
        /// <param name="node"></param>
        void renderNode(DTInspectorNode node)
        {
            if (serializedObject == null)
            {
                return;
            }
            bool            guistate = GUI.enabled;
            DTInspectorNode item;

            for (int i = 0; i < node.Items.Count; i++)
            {
                item = node[i];
                item.serializedObject = serializedObject;

                if (item.Disabled)
                {
                    GUI.enabled = false;
                }
                if (item is DTFieldNode)
                {
                    DTFieldNode field = (DTFieldNode)item;

                    field.serializedProperty = serializedObject.FindProperty(field.SerializedPropertyPath);
                    if (field.serializedProperty == null)
                    {
                        return;
                    }
                    field.Calculate();

                    if (field.Visible)
                    {
                        foreach (var act in item.Actions)
                        {
                            if (act.Position == ActionAttribute.ActionPositionEnum.Above)
                            {
                                NodeRenderer.RenderAction(item, act, this, Target);
                            }
                        }

                        if (field.ArrayEx != null)
                        {
                            field.ArrayEx.serializedProperty = field.serializedProperty;
                            field.ArrayEx.DoLayoutList();
                        }
                        else
                        {
                            NodeRenderer.RenderField(field);
                            field.raiseOnRender();
                        }

                        foreach (var act in item.Actions)
                        {
                            if (act.Position == ActionAttribute.ActionPositionEnum.Below)
                            {
                                NodeRenderer.RenderAction(item, act, this, Target);
                            }
                        }
                    }
                }
                else if (item is DTGroupNode)
                {
                    var group = (DTGroupNode)item;
                    group.Calculate();

                    if (group.Visible)
                    {
                        foreach (var act in item.Actions)
                        {
                            if (act.Position == ActionAttribute.ActionPositionEnum.Above)
                            {
                                NodeRenderer.RenderAction(item, act, this, Target);
                            }
                        }

                        if (group.Disabled)
                        {
                            GUI.enabled = false;
                        }

                        switch (item.RenderAs)
                        {
                        case DTInspectorNode.RenderAsEnum.Section:
                            NodeRenderer.RenderSectionHeader(group);
                            if (group.ContentVisible)
                            {
                                renderNode(group);
                                group.raiseOnRender();
                            }
                            NodeRenderer.RenderSectionFooter(group);
                            break;

                        case DTInspectorNode.RenderAsEnum.TabBar:
                            NodeRenderer.RenderTabBarHeader(group, (group.MaxItemsPerRow == -1) ? group.Items.Count:group.MaxItemsPerRow);
                            if (group.SelectedIndex > -1)
                            {
                                renderNode(group[group.SelectedIndex]);
                                group[group.SelectedIndex].raiseOnRender();
                            }
                            NodeRenderer.RenderTabBarFooter(group);
                            break;

                        default:
                            if (group.ContentVisible)
                            {
                                renderNode(group);
                            }
                            break;
                        }

                        foreach (var act in item.Actions)
                        {
                            if (act.Position == ActionAttribute.ActionPositionEnum.Below)
                            {
                                NodeRenderer.RenderAction(item, act, this, Target);
                            }
                        }
                    }
                }
                GUI.enabled = guistate;
                if (item.NeedRepaint)
                {
                    item.NeedRepaint = false;
                    NeedRepaint      = true;
                }
            }
        }