- Home /
how do I load a data file using a relative path?
I am using www to load a data file using a file/// path. but everytime I switch computers I have to go change the code. Is there a way to load something dynamically at runtime with a relative local path like you can do in html?
Thanks, Dan
Answer by gregzo · Dec 18, 2011 at 06:25 PM
yourVar = Resources.Load("YourFolder/YourFile"); Asset has to be in a root folder named resources. I hope that's what you were looking for!
I've used that for loading models, not for loading data. With the models I first create a game Object load the resource, then instantiate the model into the gameObject. I'm not sure how that translates to getting data out of a file. Do you know how that would work?
If you're going to use Resources, you will be restricted on where you can read your files from.
The WWW class seems to provide the most flexibility for reading files from different places.
Answer by jahroy · Dec 18, 2011 at 06:59 PM
I think your best bet is to use Application.dataPath or Applicaton.persistentData and use relative paths from there.
You can also use this kinda stuff from Mono.
Your answer
Follow this Question
Related Questions
Accessing local system ( File Browser ) 2 Answers
Saving world info 3 Answers
How do you directly add to velocity in a relative manner? 1 Answer
Imported Animations: Make Local? or Other Fix? 2 Answers
Loading text into Gui.Box 2 Answers