Search Unity

reading json file in Vector

Discussion in 'Community Learning & Teaching' started by thisisjamaldin, Jul 27, 2018.

?

reading json file in Vector

  1. ?

    0 vote(s)
    0.0%
  2. ?

    0 vote(s)
    0.0%
Multiple votes are allowed.
  1. thisisjamaldin

    thisisjamaldin

    Joined:
    Jul 23, 2018
    Posts:
    1
    My json:

    1. {
    2. "lines":[[1.0,0.0,0.0],[5.0,0.0,0.0]
    3. ]}
    my C# code:

    1. string path;
    2. string jsonString;

    3. void Start () {
    4. path = Application.streamingAssetsPath + "/acadunity.json";
    5. jsonString = File.ReadAllText(path);
    6. Creature Lines = JsonUtility.FromJson<Creature>(jsonString);
    7. Debug.Log(Lines.lines[0]);

    8. [Serializable]
    9. public class Creature{
    10. public Vector3[] lines;
    11. }
    I get:
    1. (0.0, 0.0, 0.0)
    I want to get:

    1. [1.0,0.0,0.0]