So currently I am trying to make a foliage system that allows for people to fine tune how the trees and foliage are placed in the world for massive forest. The only problem is storing thousands of positions is very difficult or impossible without making a tool to generate a string to bake an array into udon sharp. my question is “ Is there a way to store hundreds or thousands of positions without baking the array into udon code”
What I am looking for is an alternate way to efficiently store tree positional data. I know there is JSON in VRChat but no way to read files so that cant be an individual file meaning it would be baked into udon sharp. Making a public array of data could work but that still incredibly hard to interface with C# tools(from my experience). Making anything with the C# API aka Scriptable objects and mono behaviors just breaks my udon compiler so that’s not viable either.
I’m not sure this is even remotely possible to do in any other way, but you never know. there may be other ways of doing this. If not maybe we could possibly turn this into a feature request.
Any tips or ideas would be greatly appreciated
I know there is JSON in VRChat but no way to read files
You can read files. You do so by making udon code that has a “TextAsset” public variable. Then in the component slots you can give it any number of raw text formats - .txt, .json, .md, or others. These text files are recognized by unity, can be parsed by udon code, and are included when you make a build.
If you want something a little more dynamic, you may also consider remote string loading. You or the users could provide a URL where a chunk of text is hosted, and then your udon code could parse the json from that. String Loading | VRChat Creation
If you want something dynamic and automatic, you could also store data inside of persistence. You could set it up so that the changes a player makes is automatically loaded when they come back to the world, with no complex export/save/import process required of them. Though, the cost of being more automatic is that it has a smaller restriction on size - string loading can be 100MB, while persistence can only be 100KB. Persistence | VRChat Creation
1 Like
OK I kinda assumed that files were out of the question due to the sand boxing. but i guess it would make sense for a pre defined path to be allowed. Will this method allow me to store practicaly any format like binary?
yep, if you want to work with bytes directly instead of string to json you would use Unity - Scripting API: TextAsset.bytes
You’ll have to write your own parser, but you do have all the necessary utilities like bit shifting, bitwise and/or, array copying, and many others
1 Like