Пример #1
0
        public void RefreshStories()
        {
            Node[]         startNodesArray = nodes.Where(x => x.GetType() == typeof(StartElement)).ToArray();
            StartElement[] startNodes      = new StartElement[startNodesArray.Length];

            for (int i = 0; i < startNodes.Length; i++)
            {
                startNodes[i] = startNodesArray[i] as StartElement;
            }

            StoryNames = startNodes.Select(x => x.StoryName).ToArray();

            _shortStories = new List <StoryElement> [startNodes.Length];
            for (int i = 0; i < _shortStories.Length; i++)
            {
                _shortStories[i] = new List <StoryElement>();
                _shortStories[i].Add(startNodes[i]);

                StartElement currentStartNode = startNodes[i];
                StoryElement currentNode      = startNodes[i].GetOutputPort("NextNode").GetOutputValue() as StoryElement;
                while (currentNode != null && currentNode.GetOutputPort("NextNode").IsConnected&& currentNode.GetOutputPort("NextNode").GetOutputValue().GetType() != typeof(StartElement))
                {
                    _shortStories[i].Add(currentNode);
                    currentNode = currentNode.GetOutputPort("NextNode").GetOutputValue() as StoryElement;
                }
                if (currentNode != null && currentNode.GetType() != typeof(StartElement))
                {
                    _shortStories[i].Add(currentNode);
                }
            }
        }
Пример #2
0
            public override void OnBodyGUI()
            {
                Rect lastRect;

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label("Previous", EditorStyles.boldLabel);
                    NodeEditorGUILayout.AddPortField(node.GetInputPort("PreviousNode"));
                    GUILayout.Space(170f);
                    GUILayout.Label("Next", EditorStyles.boldLabel);
                    NodeEditorGUILayout.AddPortField(node.GetOutputPort("NextNode"));
                    lastRect = GUILayoutUtility.GetLastRect();
                }
                GUILayout.EndHorizontal();

                if (foldout)
                {
                    node.DisplayNodeLayout(lastRect);
                }

                GUIContent arrow;

                if (foldout)
                {
                    arrow = EditorGUIUtility.IconContent("d_Toolbar Minus");
                }
                else
                {
                    arrow = EditorGUIUtility.IconContent("d_Toolbar Plus");
                }

                if (GUILayout.Button(arrow))
                {
                    foldout = !foldout;
                }
            }