예제 #1
0
 ///Utility to start sub graph (makes instance, writes mapping, starts graph and on stop reads mapping)
 public static bool TryStartSubGraph(this IGraphAssignable assignable, Component agent, System.Action <bool> callback = null)
 {
     assignable.currentInstance = assignable.CheckInstance();
     if (assignable.currentInstance != null)
     {
         assignable.TryWriteAndBindMappedVariables();
         //we always start with the current graphs blackboard parent bb as the subgraphs parent bb
         assignable.currentInstance.StartGraph(agent, assignable.graph.blackboard.parent, Graph.UpdateMode.Manual, (result) =>
         {
             if (assignable.status == Status.Running)
             {
                 assignable.TryReadAndUnbindMappedVariables();
             }
             if (callback != null)
             {
                 callback(result);
             }
         });
         return(true);
     }
     return(false);
 }