- Home /
How can i send and read a float list from server to Unity using Socket IO for Unity?
Hello, like the title suggest, i'm trying to send a list of floats,like (0.3,0.3,0.5,1,1,1,1.2), in a form of Json object. I Have tried to store the list in a class using JsonUtility.FromJson but it just store as integrals and nulls where i have 0.something. I also tried to get the list into float format, using E.data.GetField("values").f, but it only output the value 0. Does Anyone have a clue how can i work with list of floats using socket io and json objects?
Answer by qsp18 · Dec 07, 2020 at 03:54 PM
A List is not an Object. Maybe you should import another Json Asset for non-objects. Try this Json.net: https://assetstore.unity.com/packages/tools/input-management/json-net-for-unity-11347
And then use the JsonConvert.Serialize and JsonConvert.Deserialize
I know that a list is not an object. Im sending from my server an object like msg={id: 1, values[0.2, 0.3, 1,1,1.2]}. I tryed to store the values in a class where i have the exact same fields to act like a class data holder but that didn't work
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
How do you know if a value is a list? 0 Answers
New constructor help needed for JSON keyvalue pair 0 Answers
Why is JSON not saving my Class? 2 Answers
UnityScript for unique simpleJSON lists 0 Answers