protected override void SaveDataToAINode(AI.BehaviorTree tree, SaveTreeGraphNodeAsset nodeAssetSaver)
        {
            if (!IsValid())
            {
                return;
            }

            if (!UnityEditor.AssetDatabase.Contains(sourceNode))
            {
                AI.Node aiNode = tree.CreateNode(sourceNode);
                nodeAssetSaver.Invoke(this, aiNode.name);
            }

            List <NodeInfo> nextNodes   = GetNextNodes();
            List <AI.Node>  nextAINodes = new List <AI.Node>();

            foreach (NodeInfo bn in nextNodes)
            {
                nextAINodes.Add(bn.node.GetAINode());
            }

            sourceNode.sequenceNodes = nextAINodes.ToArray();

            UnityEditor.EditorUtility.SetDirty(this);
            UnityEditor.EditorUtility.SetDirty(sourceNode);
        }
Esempio n. 2
0
        protected override void SaveDataToAINode(AI.BehaviorTree tree, SaveTreeGraphNodeAsset nodeAssetSaver)
        {
            if (!IsValid())
            {
                return;
            }

            if (!UnityEditor.AssetDatabase.Contains(sourceNode))
            {
                AI.Node aiNode = tree.CreateNode(sourceNode);
                nodeAssetSaver.Invoke(this, aiNode.name);
            }

            //Confirms that the nodeBehavior is saved to AssetDatabase
            sourceNode.NodeBehavior = sourceNode.NodeBehavior;

            UnityEditor.EditorUtility.SetDirty(this);
            UnityEditor.EditorUtility.SetDirty(sourceNode);
        }
        protected override void SaveDataToAINode(AI.BehaviorTree tree, SaveTreeGraphNodeAsset nodeAssetSaver)
        {
            if (!IsValid())
            {
                return;
            }

            if (!UnityEditor.AssetDatabase.Contains(sourceNode))
            {
                AI.Node aiNode = tree.CreateNode(sourceNode);
                nodeAssetSaver.Invoke(this, aiNode.name);
            }

            List <NodeInfo> nextNodes = GetNextNodes();

            foreach (NodeInfo bn in nextNodes)
            {
                if (bn.inSlot.name == "true:")
                {
                    sourceNode.nodeOnTrue = bn.node.GetAINode();
                }
                if (bn.inSlot.name == "false:")
                {
                    sourceNode.nodeOnFalse = bn.node.GetAINode();
                }
            }

            if (sourceNode.Logic == null)
            {
                sourceNode.Logic = new SelectorLogic();
            }
            sourceNode.Logic.PropertyOneToEvaluate = PropertyOneToEvaluate;
            sourceNode.Logic.Mode = Mode;

            switch (PropertyTwoType)
            {
            case PropertyType.BLACKBOARD:
            {
                sourceNode.Logic.PropertyTwoToEvaluate = PropertyTwoToEvaluate;
                break;
            }

            case PropertyType.BOOL:
            {
                sourceNode.Logic.PropertyTwoToEvaluate = "(bool)" + PropertyTwoToEvaluate;
                break;
            }

            case PropertyType.FLOAT:
            {
                sourceNode.Logic.PropertyTwoToEvaluate = "(float)" + PropertyTwoToEvaluate;
                break;
            }

            case PropertyType.INT:
            {
                sourceNode.Logic.PropertyTwoToEvaluate = "(int)" + PropertyTwoToEvaluate;
                break;
            }
            }

            UnityEditor.EditorUtility.SetDirty(this);
            UnityEditor.EditorUtility.SetDirty(sourceNode);
        }