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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Import Json Map and Render it

Discussion in '2D' started by B_Johansson, Apr 24, 2022.

  1. B_Johansson

    B_Johansson

    Joined:
    Jul 21, 2017
    Posts:
    13
    Problem:
    I have created a mmorpg in .NET and I'm now working on a client port to Unity. In my mmorpg I have map files in the json format that I intend to load into unity and render from code.

    Now, I've been googling but I can not find any such example. All I see is info about the Tilemap system. I have seen Tiled2Unity but I do not use Tiledmaps. I use my own custom maps. I have no issues with loading the data, just a matter of what I do with my loaded map object in C# to blit it to the screen.

    Goal:
    I want to load the map files into memory and render the needed graphics to the screen. Preferably to be able to create a tile from C# script and put it into a tilemap for example.

    Questions:
    Do anybody know where I should be looking or searching for?

    Any info is appreciated!
     
    Last edited: Apr 24, 2022
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,947
    What does this mean? A heightmap? A grid of tiles? A list of lines? A link to a terrain file?

    To see what I mean, pick one piece of data in your JSON, such as this:

    {
    "oneTileData": 123456
    }


    ... and go explain exactly what the payload field
    123456
    means.

    And by "what it means" you need to specify what code steps are taken, such as:

    "load sprite named 123456 and place it in this tile spot."
     
  3. B_Johansson

    B_Johansson

    Joined:
    Jul 21, 2017
    Posts:
    13
    I didn't think the content would matter, as regardless of the data, I want to render it from code as that is where the map data will be.

    My map file holds an array of (x,y) for each tile on the map. What graphic used for each tile is determined by a X/Y position on an image. So the goal is basically to render a 32*32 from an image to the screen.

    Example: