Giter Site home page Giter Site logo

Comments (7)

cainhuang avatar cainhuang commented on May 2, 2024

这个静态变量初始化时机没有问题,因为BehaviorLoaderImplement肯定在AgentMeta::checkSignature()方法被调用前就初始化好了。
如果报这个错,说明你们导出的行为树文件比那个behaviac_agent_meta.cpp文件要新一些,也即可能导出的行为树文件中用到了新加的Agent子类或其成员属性和方法,需要重新导出behaviac_agent_meta.cpp文件,这样最新的元信息胶水代码才能跟导出的最新的行为树文件匹配上。

from behaviac.

chenditc avatar chenditc commented on May 2, 2024

我用 gdb 断点调试了一下,第一次调用 checkSignature 的时候,signature 尚未被赋值,仍然是 0,并且 BehaviorLoaderImplement 构造器的构造器并没有被调用。

可以这样重现:

  1. 导出行为树 cpp 文件以及 xml
  2. 将导出的文件编译为 .a 静态库
  3. 编译测试代码
  4. 将 .a 行为树静态库 link 进测试代码成可执行文件

from behaviac.

cainhuang avatar cainhuang commented on May 2, 2024

这种情况,需要在你游戏初始化的地方调用InitBehaviorLoader(),
在你游戏退出的地方调用DestroyBehaviorLoader()

这两个接口声明在meta.h中,实现在导出的behaviac_agent_meta.cpp,不用自己添加任何代码,直接调用这2个接口行了

from behaviac.

chenditc avatar chenditc commented on May 2, 2024

Ok, 这个做法是可以的。希望这个可以加入文档以及教程中,让新手更容易上手。

from behaviac.

cainhuang avatar cainhuang commented on May 2, 2024

好,我先放在bbs问题里面去了

from behaviac.

v012345 avatar v012345 commented on May 2, 2024

确实 我是作为 .lib 来使用 behaviac_generated , static BehaviorLoaderImplement _behaviorLoaderImplement_; 就完全不是初始化;
之后把 behaviac_generated 里的 cpp 文件直接放到 exe 里就没有这个问题了

from behaviac.

wumohai avatar wumohai commented on May 2, 2024

from behaviac.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.