Behavior tree Behaviourtree

using System.Collections;
using System.Collections.Generic;
using UnityEditorInternal;
using UnityEngine;
using UnityEditor;

[CreateAssetMenu()]
public class BehaviourTree : ScriptableObject
{

    public Node rootNode;

    public Node.State treeState = Node.State.Running;
    public List<Node> nodes = new List<Node>();
    public Blackboard blackboard = new Blackboard();

    public Node.State Update()
    {
        if (rootNode.state==Node.State.Running)
        {
            treeState = rootNode.Update();
        }
        return treeState;
    }
# if UNITY_EDITOR
    public Node CreateNode(System.Type type)
    {

        Node node=ScriptableObject.CreateInstance(type) as Node;
        node.name = type.Name;
        node.guid = GUID.Generate().ToString();

        Undo.RecordObject(this, "Behaviour Tree (CreateNode)");

        nodes.Add(node);
        if (!Application.isPlaying)
        {
            AssetDatabas

Guess you like

Origin blog.csdn.net/zhuangjialo/article/details/122710097