question

doronhn avatar image
doronhn asked

Entities | when i try to save int its change it to bool, even the number is 30

Hey,

i am trying to work with entities in unity (C#).

when i trying to create object with int values, the SetObject change it to bool, even if its high number.

do i need to save it as string? why?

entities
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Andy avatar image Andy ♦♦ commented ·

Can you provide more specifics? What does your SetObjects request look like and what does the GetObjects call return afterwards?

0 Likes 0 ·
doronhn avatar image doronhn Andy ♦♦ commented ·

this is the full info:

1. "PlayerLevel" Class:

    public int ID;
    public int Stars;
    public PowerUps PowerupsTaken;

2. "PowerUps" Class:

    public int UndoMove;
    public int Teleport;
    public int Hint;
    public int TileStamp;

3. Reuest:

var data = new List<PlayerLevel>();
data.Add(new PlayerLevel() 
{
ID = 1, Stars = 0,
PowerupsTaken = new PowerUps()
{
Hint=0,
Teleport=0,
TileStamp=0,
UndoMove=0
}
}); var dataList = new List<SetObject>() { new SetObject() { ObjectName = "PlayerLevelsList", DataObject = data }, new SetObject() { ObjectName = "CurrentLevel", DataObject = "1" } };

4. This is the result in the PlayFab game manager:

What do you think?

0 Likes 0 ·
playfab.png (10.4 KiB)

1 Answer

·
Andy avatar image
Andy answered

It looks like the JSON serializer on the C# side is interpreting the 1 and 0s as booleans. You can try putting them in quotes or writing the JSON yourself. Also, to isolate the problem to the client side, you can try grabbing a fiddler trace to determine whether the values are leaving the client as Booleans or Ints.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

samirduran avatar image samirduran commented ·

Just for the record, this was exactly what was happening to me. Putting all the information as string solved the problem.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.