public void InstantiateOrOpenConditionEditor(XNode.Node targetNode)
        {
            TransitionNode   node      = targetNode as TransitionNode;
            ConditionalGraph condGraph = node.conditionGraph;

            if (condGraph == null)
            {
                condGraph = CreateNewConditionalGraph(node);
            }

            NodeEditorWindow.Open(condGraph);
        }
Esempio n. 2
0
        private void MoveNextTransition(Node connectingNode)
        {
            if (connectingNode is TransitionNode)
            {
                TransitionNode node             = connectingNode as TransitionNode;
                bool           shouldTransition = node.ShouldTransition();
                NodePort       branchPort       = node.GetTransitionPath(shouldTransition);
                Node           nextNode         = branchPort.node;

                if (nextNode == null)
                {
                    return;
                }
                MoveNextImmediateState(nextNode);
                MoveNextTransition(nextNode);
                MoveNextForwarded(nextNode);
            }
        }
        /// <summary>
        /// Creates a new conditional graph as an asset
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public ConditionalGraph CreateNewConditionalGraph(TransitionNode node)
        {
            ConditionalGraph condGraph = ScriptableObject.CreateInstance <ConditionalGraph>();
            string           nodePath  = AssetDatabase.GetAssetPath(node);

            string condPath = nodePath.Substring(0, nodePath.LastIndexOf("/") + 1);

            condPath      += "cndGraph_" + node.graph.name + "_" + node.name + ".asset";
            condGraph.name = node.graph.name + "_" + node.name + "_ConditionalGraph";
            string finalPath = AssetDatabase.GenerateUniqueAssetPath(condPath);

            AssetDatabase.CreateAsset(condGraph, finalPath);

            node.conditionGraph  = condGraph;
            condGraph.parentNode = node;

            ConditionalRootNode rootnode = condGraph.AddNode <ConditionalRootNode>();

            rootnode.name = "Condition Root Node";
            AssetDatabase.AddObjectToAsset(rootnode, condGraph);

            condGraph.rootNode = rootnode;
            return(condGraph);
        }