Calling CloudCode throws a DeserializationException.
The strange thing is that ItemDataA does not throw a DeserializationException but ItemDataB does
- DataClass A
namespace MyGameData;
public class ItemDataA
{
public int itemId;
public int count;
}
- DataClass B
namespace MyGameData;
public class ItemDataB
{
public int itemId;
public int count;
}
- CloudCode
[CloudCodeFunction("GetData")]
public async Task<ItemDataA> ResponseTest(IExecutionContext context, IGameApiClient gameApiClient)
{
return new ItemDataA() { itemId = 1000 , count = 10 };
}
- UnityCode
public async void GetItem()
{
try
{
var result = await CloudCodeService.Instance.CallModuleEndpointAsync<ItemDataA>("GamePlayModule", "GetData");
}
catch (CloudCodeException e)
{
Debug.Log(e.ToString());
}
}
In the case of the ItemDataA class, it runs normally, but
When running with the ItemDataB class, a DeserializationException occurs.
However, both run normally in the Unity Editor.
When building and running APK, DeserializationException occurs only in ItemDataB.
-Error
Unity.Services.CloudCode.Internal.Http.DeserializationException: Unable to find a constructor to use for type MyGameData.ItemDataB. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute. Path ‘count’, line 1, position 9.
I don’t know the cause
Is there anything I can try?