コード例 #1
0
    public static void Draw(NodeValue nodeValue, int selectNodeId, float value = 0f)
    {
        nodeValue.position.height = GetHight(nodeValue);
        height = (int)nodeValue.position.height - 15;

        EditorGUILayout.BeginVertical(/*"box",*/ GUILayout.Height(height));
        {
            Rect backRect = new Rect(5, 20, nodeValue.position.width - 10, height - 8);
            GUI.backgroundColor = GetColor(nodeValue, selectNodeId);
            GUI.Box(backRect, string.Empty);
            GUI.backgroundColor = Color.white;

            string idMsg = string.Empty;
            if (nodeValue.NodeType == (int)NODE_TYPE.SUB_TREE)
            {
                idMsg = string.Format("子树ID:{0}", nodeValue.id);
            }
            else
            {
                if (nodeValue.NodeType == (int)NODE_TYPE.CONDITION)
                {
                    idMsg = string.Format("条件ID:{0}", nodeValue.id);
                }
                else if (nodeValue.NodeType == (int)NODE_TYPE.ACTION)
                {
                    idMsg = string.Format("行为ID:{0}", nodeValue.id);
                }
                else
                {
                    idMsg = string.Format("ID:{0}", nodeValue.id);
                }
            }
            EditorGUILayout.LabelField(idMsg);

            nodeValue.descript = EditorGUILayout.TextField(nodeValue.descript);

            int        resultIntType = (int)ResultType.Fail;
            float      slider        = NodeNotify.NodeDraw(nodeValue.id, ref resultIntType);
            ResultType resultType    = (ResultType)resultIntType;

            Rect runRect = new Rect(8, height, nodeValue.position.width - 16, 8);
            GUI.Box(runRect, string.Empty);
            if (slider > 0)
            {
                runRect.width       = runRect.width * slider;
                GUI.backgroundColor = GetSliderColor(resultType);
                GUI.Box(runRect, string.Empty);
                GUI.backgroundColor = Color.white;
            }
        }
        EditorGUILayout.EndVertical();
    }
コード例 #2
0
    public static void Draw(NodeValue nodeValue, int selectNodeId, float value = 0f)
    {
        EditorGUILayout.BeginVertical("box", GUILayout.Height(height));
        {
            if (nodeValue.id == selectNodeId)
            {
                GUI.backgroundColor = new Color(0, 1, 0, 0.15f);
                GUI.Box(new Rect(5, 20, nodeValue.position.width - 10, height), string.Empty);
                GUI.backgroundColor = Color.white;
            }

            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField(new GUIContent("根节点"), GUILayout.Width(50));
                nodeValue.isRootNode = EditorGUILayout.Toggle(nodeValue.isRootNode, GUILayout.Width(50));
            }
            EditorGUILayout.EndHorizontal();

            int parentID = nodeValue.parentNodeID;
            //if (parentID > 0)
            {
                string msg = string.Format("父节点_{0}", parentID);
                EditorGUILayout.LabelField(msg);
            }

            nodeValue.descript = EditorGUILayout.TextArea(nodeValue.descript);

            {
                float slider = NodeNotify.NodeDraw(nodeValue.id);

                Rect runRect = new Rect(8, 80, nodeValue.position.width - 16, 8);
                GUI.Box(runRect, string.Empty);
                if (slider > 0)
                {
                    runRect.width       = runRect.width * slider;
                    GUI.backgroundColor = Color.green;
                    GUI.Box(runRect, string.Empty);
                    GUI.backgroundColor = Color.white;
                }
            }

            //GUILayout.HorizontalSlider(value, 0, 1);
        }
        EditorGUILayout.EndVertical();

        SetHight(nodeValue);
    }