小编Clo*_*udL的帖子

如何在Unity/C# WebGL平台中调用async/await JavaScript函数?

我按照这个文档从 Unity 中的 C# 脚本调用 JavaScript 函数来制作 WebGL 游戏。

但是如果js代码中包含async/await就会出现问题,例如:

C# 脚本:

    [DllImport("__Internal")]
    private static extern void Foo();

    [DllImport("__Internal")]
    private static extern void Boo();

    void Start(){
      Foo();
      Boo();
    }
Run Code Online (Sandbox Code Playgroud)

JavaScriptmylib.jslib

mergeInto(LibraryManager.library, {
  // works well
  Foo: function () {
    window.alert("Hello, world!");
  },

  // error: can't compile
  Boo: async function (){
    var s = function (ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
    };
    await s(2000);
    window.alert("Boo!");
  }
});
Run Code Online (Sandbox Code Playgroud)

当我尝试构建这些代码时,它显示错误如下:

Failed process stderr log:
error: failure to execute …
Run Code Online (Sandbox Code Playgroud)

javascript c# unity-game-engine webgl async-await

6
推荐指数
1
解决办法
4038
查看次数

CMake错误,配置“为可执行目标“ assimp_simpletexturedogl”未提供运行时目的地的安装目标时,”。

我正在尝试使用CMake配置assimp的示例

但是配置时有一些错误

我已经尝试了很多方法,但是没有人起作用。

CMake Error at CMakeLists.txt:41 (INSTALL):
      install TARGETS given no RUNTIME DESTINATION for executable target
      "assimp_simpletexturedogl".


    CMake Warning (dev) in CMakeLists.txt:
      No cmake_minimum_required command is present.  A line of code such as

        cmake_minimum_required(VERSION 3.2)

      should be added at the top of the file.  The version specified may be lower
      if you wish to support older CMake versions for this project.  For more
      information run "cmake --help-policy CMP0000".
    This warning is for project developers.  Use -Wno-dev to suppress it. …
Run Code Online (Sandbox Code Playgroud)

configuration makefile cmake assimp cmake-gui

4
推荐指数
1
解决办法
8470
查看次数

如何在Unity3D中使用多线程进行AI

我正在制作带有AI的Unity3D国际象棋游戏.

当AI正在寻找一个好的举动时,我的游戏屏幕停滞不前.

AI通常需要大约5~30秒才能思考.

我知道这是因为我的CPU资源专门用于计算AI.

但我打开任务管理器,我发现我的游戏只使用了50%的CPU,可能是因为我的计算机是intel核心2,并且有2个线程.

所以我在想的是:

Unity(或C#)是否可以在一个线程中进行AI计算,并将游戏玩法保存在另一个线程中?

所以玩家在AI计算时不会看到卡住的画面.

我听过Delegate或Event,但我仍然不知道多线程之间的关系.

c# multithreading delegates artificial-intelligence unity-game-engine

1
推荐指数
1
解决办法
5278
查看次数