예제 #1
0
    private void showStoryProperties()
    {
        if (currenStory != null)
        {
            EditorGUILayout.BeginVertical(rootGroupStyle);
            using (var h = new EditorGUILayout.HorizontalScope())
            {
                currenStory.id   = EditorGUILayout.IntField("剧情ID:", currenStory.id);
                currenStory.name = EditorGUILayout.TextField("剧情名字:", currenStory.name);
                bool toggle = GUILayout.Toggle(currenStory.scene == 1, "是场景剧情");
                currenStory.scene  = toggle ? 1 : 0;
                enableAddAndRemove = GUILayout.Toggle(enableAddAndRemove, "是否启用增删功能");
            }

            if (currenStory.step.Length > 0)
            {
                drawSteps();
            }

            if (enableAddAndRemove && GUILayout.Button("添加剧情步骤"))
            {
                List <StoryXMLNode> tempList = new List <StoryXMLNode>(currenStory.step);
                StoryXMLNode        node     = new StoryXMLNode();
                tempList.Add(node);
                currenStory.step = tempList.ToArray();
                bShowSteps.Clear();
            }
            EditorGUILayout.EndVertical();
        }
    }
예제 #2
0
    private void drawSteps()
    {
        var steps = currenStory.step;

        if (bShowSteps.Count <= 0)
        {
            foreach (var step in steps)
            {
                bShowSteps.Add(true);
            }
        }

        EditorGUILayout.BeginVertical(rootGroupStyle);
        int removeIndex = -1;

        stepListScrollPos = EditorGUILayout.BeginScrollView(stepListScrollPos);
        for (int i = 0; i < steps.Length; ++i)
        {
            EditorGUILayout.BeginVertical(subGroupStyle);
            StoryXMLNode stepNode = steps[i];
            using (var h = new EditorGUILayout.HorizontalScope()) {
                bShowSteps[i]     = EditorGUILayout.Foldout(bShowSteps[i], "步骤(" + (i + 1) + ")");
                stepNode.lastTime = EditorGUILayout.FloatField("步骤结束时间:", stepNode.lastTime);
            }
            var actions = stepNode.node;
            if (bShowSteps[i])
            {
                int removeActionIndex = -1;
                for (int j = 0; j < actions.Length; ++j)
                {
                    EditorGUILayout.BeginVertical(subGroupStyle);
                    var action = actions[j];
                    drawAction(action);

                    if (enableAddAndRemove && GUILayout.Button("删除这个Action"))
                    {
                        removeActionIndex = j;
                    }
                    EditorGUILayout.EndVertical();
                }
                if (removeActionIndex >= 0)
                {
                    List <StoryActionNode> tempActionList = new List <StoryActionNode>(actions);
                    tempActionList.RemoveAt(removeActionIndex);
                    stepNode.node = tempActionList.ToArray();
                }
            }

            using (var h = new EditorGUILayout.HorizontalScope())
            {
                if (enableAddAndRemove && GUILayout.Button("添加Action"))
                {
                    List <StoryActionNode> tempActionList = new List <StoryActionNode>(actions);
                    StoryActionNode        action         = new StoryActionNode();
                    tempActionList.Add(action);
                    stepNode.node = tempActionList.ToArray();
                }
                if (enableAddAndRemove && GUILayout.Button("删除这一步骤"))
                {
                    removeIndex = i;
                }
            }

            EditorGUILayout.EndVertical();
        }

        if (removeIndex >= 0)
        {
            List <StoryXMLNode> tempList = new List <StoryXMLNode>(steps);
            tempList.RemoveAt(removeIndex);
            currenStory.step = tempList.ToArray();
            bShowSteps.Clear();
        }
        EditorGUILayout.EndScrollView();

        EditorGUILayout.EndVertical();
    }