playMaker

Author Topic: Load Json File  (Read 2721 times)

ken168

  • Playmaker Newbie
  • *
  • Posts: 11
Load Json File
« on: December 23, 2024, 07:37:35 AM »
Hello everyone:

I want to use json files to record some data, such as the value of items, and read them in the game. I store the json files in
Asset/StreamingAssets

But when I run the game, I can't find the file?
Is my setting correct?
Thanks

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15620
  • Official Playmaker Support
Re: Load Json File
« Reply #1 on: December 26, 2024, 05:56:40 AM »
Hi,

How do you get the streamingAssets folder? you need to use an action for this, that use the Unity api to give the proper relative path.

 Log in the console the full path you get at runtime, and see if it matches.

you don't really need the streaming assets for this, simply have it in your assets, as a text asset.

if you want to record data while playing a game and save it. then you MUST use the persistent data folder, streaming assets can not be written, they can only be read. it's not recommanded to try to use it otherwise.

Bye,

Jean

Bye,

Jean

ken168

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Load Json File
« Reply #2 on: December 26, 2024, 09:32:05 AM »
Hello, thank you for your reply

I use this json file without any intention of writing data.
Just use it to store data, such as: weapons and equipment, etc., a large number of props data,
for the game to read

That's why I tried to use the streamingAssets folder, and I also planned to store this file in a network folder in the future.

This time I put the json file in the Resources folder.
It's just that I can't find a way to read this json file correctly.

The result of reading is the content of the json file, but the data I want is not stored individually.