Exemplo n.º 1
0
        private void DrawSelf()
        {
            string           label     = m_node.Title;
            BTGraphNodeStyle nodeStyle = BTEditorStyle.GetNodeStyle(m_node);
            Vector2          nodeSize  = BTEditorStyle.GetNodeSize(m_node);
            Rect             position  = new Rect(NodePosition + BTEditorCanvas.Current.Position, nodeSize);
            RunningStatus    status    = BTEditorCanvas.Current.IsDebuging ? GetNodeStatus(m_node) : RunningStatus.None;

            GUI.Box(position, "", nodeStyle.GetStyle(status, m_isSelected));

            int  iconSize    = 32;
            int  iconOffsetY = 7;
            Rect iconPos     = new Rect(position.x + (nodeSize.x - iconSize) / 2, position.y + (nodeSize.y - iconSize) / 2 - iconOffsetY, iconSize, iconSize);

            GUI.DrawTexture(iconPos, BTEditorStyle.GetNodeIcon(m_node));

            Rect titlePos = new Rect(position);

            titlePos.y = titlePos.y - 5;
            EditorGUI.LabelField(titlePos, label, BTEditorStyle.NodeTitleLabel);

            // show index of composite's children.
            if (Parent != null && Parent.Node is Composite)
            {
                Composite compNode    = Parent.Node as Composite;
                int       index       = compNode.GetIndex(m_node);
                Rect      nodeLeftPos = new Rect(position.x + 2, position.center.y - 8, 20, 16);
                EditorGUI.LabelField(nodeLeftPos, index.ToString(), EditorStyles.label);
            }

            if (m_node.Breakpoint != Breakpoint.None)
            {
                Rect imgPosition;
                if (m_node is NodeGroup)
                {
                    imgPosition = new Rect(position.x + 2, position.y + 2, 12, 12);
                }
                else
                {
                    imgPosition = new Rect(position.x + 2, position.y + 2, 12, 12);
                }

                GUI.DrawTexture(imgPosition, BTEditorStyle.Breakpoint);
            }

            // show obsolete icon
            if (BTNodeObsoleteFactory.IsObsolete(m_node))
            {
                int  obsSize     = 24;
                Rect obsoletePos = new Rect(position.x + nodeSize.x - obsSize - 5, position.y + 5, obsSize, obsSize);
                GUI.DrawTexture(obsoletePos, BTEditorStyle.WarningIcon);
            }
        }
Exemplo n.º 2
0
        private static void CreateNodeStyles()
        {
            if (m_compositeStyle == null)
            {
                m_compositeStyle = new BTGraphNodeStyle("flow node 1", "flow node 1 on",
                                                        "flow node 6", "flow node 6 on",
                                                        "flow node 4", "flow node 4 on",
                                                        "flow node 3", "flow node 3 on");
            }

            if (m_decoratorStyle == null)
            {
                m_decoratorStyle = new BTGraphNodeStyle("flow node 1", "flow node 1 on",
                                                        "flow node 6", "flow node 6 on",
                                                        "flow node 4", "flow node 4 on",
                                                        "flow node 3", "flow node 3 on");
            }

            if (m_actionStyle == null)
            {
                m_actionStyle = new BTGraphNodeStyle("flow node 0", "flow node 0 on",
                                                     "flow node 6", "flow node 6 on",
                                                     "flow node 4", "flow node 4 on",
                                                     "flow node 3", "flow node 3 on");
            }

            if (m_nodeGroupStyle == null)
            {
                m_nodeGroupStyle = new BTGraphNodeStyle("flow node 1", "flow node 1 on",
                                                        "flow node 6", "flow node 6 on",
                                                        "flow node 4", "flow node 4 on",
                                                        "flow node 3", "flow node 3 on");

                /*new BTGraphNodeStyle("flow node hex 1", "flow node hex 1 on",
                 *                                                              "flow node hex 6", "flow node hex 6 on",
                 *                                                              "flow node hex 4", "flow node hex 4 on",
                 *                                                              "flow node hex 3", "flow node hex 3 on");*/
            }
        }