首页 > 解决方案 > 使用gamesparks RTDataBuilder发送字符串,如果索引大于128就会出现IndexOutOfRange异常

问题描述

如果索引大于 128,那么我们统一得到“IndexOutOfRange Exception”。

using (RTData data = RTData.Get())
  {
      data.SetVector3(129, v); // Exception here
      data.SetString(129, "Checking");   // Exception here
      gameSparksRTUnity.SendData(4, GameSparksRT.DeliveryIntent.RELIABLE, data);
}

有没有办法发送索引大于 128 的 vector3 或字符串?还是我做错了什么。

标签: c#unity3dgamesparks

解决方案


有没有办法发送索引大于 128 的 vector3 或字符串?还是我做错了什么

不,你没有做错任何事。这是 Gamesparks 施加的限制。

RTData.SetVector3或类似的函数被调用时,它会调用RTData.SetRTVector设置一个名为 的局部数组变量的函数data

这是该数组变量的声明方式:

internal RTVal[] data = new RTVal[0x80];

0x80 转换为十进制,128因此您只能使用介于0和之间的值,127就像在 C# 中的任何数组中一样。


推荐阅读