zombieyang / puerts_unity_webgl_demo

在Unity里用Typescript写小游戏/Web游戏
BSD 3-Clause "New" or "Revised" License
190 stars 68 forks source link

[unity] 版本2.0.5使用ArrayBuffer从TS端向C#端传数据,C#端拿到的数据不正确 #66

Closed UltimateEternal closed 4 months ago

UltimateEternal commented 4 months ago

error log | 日志或报错信息

C#端代码:

  public static void TestArrayBuffer(Puerts.ArrayBuffer buffer)
  {
      StringBuilder builder = new StringBuilder();
      byte[] bytes = buffer.Bytes;
      int length = buffer.Count;

      for (int i = 0; i < length; ++i)
      {
          builder.Append($"{bytes[i]} ");
      }
      Debug.Log($"TestArrayBuffer: {builder.ToString()}");
  }

js代码:

let buffer = new ArrayBuffer(8);
let view = new DataView(buffer);
view.setUint32(0, 90008, false);
CS.AppDelegate.TestArrayBuffer(buffer);

输出结果: TestArrayBuffer: 68 189 44 0 68 189 44 0

context | 编译/运行环境

团结引擎1.2.0+Puerts WebGL 2.0.5+微信开发者工具

how to reproduce | 复现步骤

1.编写C#代码并导出wrapper 2.导出微信小游戏工程 3.运行

CCxin commented 4 months ago

重新build一下puerts-runtime.js 路径:puerts_unity_webgl_demo\packages\webgl\upm\Javascripts~