最近在用Behavior Designer,其中需要用到消息机制,看了一下其中自带了这套东西

 

注册

Owner.RegisterEvent<string>("Message", Message);

 

反注册

Owner.UnregisterEvent<string>("Message", Message);

 

发送消息

Owner.SendEvent("Message", "Finished B Action");

 

外部发送

public class Test : MonoBehaviour
{
    public BehaviorTree bt;


    void Start()
    {
        bt.SendEvent("Message", "Finished B Action");
    }
}

 

需要注意,不能跨行为树发布消息。但可以取到对象上的行为树组件,然后发送

相关文章:

  • 2021-07-06
  • 2022-12-23
  • 2022-12-23
  • 2021-10-29
  • 2021-07-20
  • 2022-12-23
  • 2021-08-11
猜你喜欢
  • 2021-11-26
  • 2022-02-08
  • 2022-02-08
  • 2021-05-28
  • 2022-12-23
  • 2022-01-06
相关资源
相似解决方案