playMaker

Author Topic: Load JSON data in Scripr List and want to use in FSM  (Read 520 times)

carlosrovira

  • Playmaker Newbie
  • *
  • Posts: 8
Load JSON data in Scripr List and want to use in FSM
« on: March 15, 2021, 06:59:15 PM »
Hi,

I load a JSON file with data (using Newtonsoft.Json) to create my in game map screens in a script List.

Code: [Select]
public List<ScreenData> screens;
When I run the game I can see the data in my "MapManager" GameObject populated on the fly.

Then I want to use a FSM to access the "screens" List instance, take and item in the list and use the data to draw a screen creating prefabs based on that data.

A sample data in my JSON for a screen is:

Code: [Select]
       {
            "id": 6,
            "blocks": [
                {
                    "content": "W",
                    "position": {"x": 0, "y": 0, "z": 0}
                },
                {
                    "content": "B",
                    "position": {"x": 2, "y": 0, "z": 2}
                }
            ]
        }

So inside the item I have an Array of "Block" (another class) with content and position. If I have a "W" I'll create a prefab assigned to that W, if is "B", the prefab for "B"

How Can I do this?

Thanks in advance!