Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

using json file for spawning waypoints in unity

Discussion in 'Editor & General Support' started by DVloperDev, Nov 1, 2021.

  1. DVloperDev

    DVloperDev

    Joined:
    Jun 1, 2021
    Posts:
    1
    i have attached a txt file from which i am generating waypoints , i am unable to understand how can i generate new custom waypoints because doing it manually is out the the question, mainly , i am having trouble understanding the $ref and $id , and how they are referring to the points, i know my question is not clear but i am so confused at this i can't even understand what how to ask.

    main question is i want to make my own file like that, i don't know how to (i mean i can create a simple json file and use the data store in it) but $ref is confusing me ,

    and please if i am not posting it in the right section do tell me where should i ask this.
     

    Attached Files:

  2. vadimtihonyuk

    vadimtihonyuk

    Joined:
    Feb 26, 2018
    Posts:
    32
    You should check Newtonsoft.JSON library and read manual for it.
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,749
    Work through some basic JSON tutorials. No sense in someone retyping it all here for you.

    Also, as Vadim suggests above, there are many well-known problems with Unity "tiny lite" built-in JSON:

    In general I highly suggest staying away from Unity's JSON "tiny lite" package. It's really not very capable at all and will silently fail on very common data structures, such as Dictionaries and Hashes and ALL properties.

    Instead grab Newtonsoft JSON .NET off the asset store for free, or else install it from the Unity Package Manager (Window -> Package Manager).

    https://forum.unity.com/threads/jso...-not-working-as-expected.722783/#post-4824743

    https://assetstore.unity.com/packages/tools/input-management/json-net-for-unity-11347

    Also, always be sure to leverage sites like:

    https://jsonlint.com
    https://json2csharp.com
    https://csharp2json.io

    PS: for folks howling about how NewtonSoft JSON .NET will "add too much size" to your game, JSON .NET is like 307k in size, and it has the important advantage that it actually works the way you expect a JSON serializer to work in the year 2021.
     
  4. vadimtihonyuk

    vadimtihonyuk

    Joined:
    Feb 26, 2018
    Posts:
    32

    Piplz could also setup link xml to keep only used parts of NewtonSoft JSON .NET