public override void OnInitData(BehaviourTreeRunner btree, string jsonData)
        {
            JObject obj = JsonConvert.DeserializeObject <JObject>(jsonData);

            mAssetPath = obj.Value <string>("asset");

            BehaviourTreeAsset asset = Resources.Load <BehaviourTreeAsset>(mAssetPath);

            if (!asset)
            {
                Debug.LogError("Can't load behaviour asset: " + mAssetPath);
                return;
            }
            BTNodeBase tree = asset.CreateBehaviourTree(btree);

            mLooper = new BehaviourLooper(tree);
        }
Example #2
0
 public void SetAsset(BehaviourTreeAsset behaviourAsset)
 {
     if (behaviourAsset == mAsset)
     {
         return;
     }
     mAsset = behaviourAsset;
     if (mAsset != null)
     {
         mRootNode = mAsset.CreateBehaviourTree(this);
         mLooper   = new BehaviourLooper(mRootNode);
     }
     else
     {
         mRootNode = null;
         mLooper   = null;
     }
 }