- Home /
dynamically locate the game EXE in unityscript
Hi, im looking for a way to locate the game exe directory (not the gamename_data folder but the actual game directory where the .exe is located) This is for part of a dynamic music loading system for a project im working on. currently the system uses Application.dataPath then a substring is applied removing the end portion (in this case the assets portion due to this being a test build using the editor), here's the actual code:
var dataloc : String = Application.dataPath.Substring(0,Application.dataPath.length - " Asset".length);
then i just call dataloc within the www var. my problem with this is i'd rather not have all the substring stuff and instead just have a direct path to avoid as many problems as possible. if the way i have it currently is the only way that will work then so be it but i'd be hard pressed not to at least ask!
Note: This current method DOES WORK! Its just that im skeptical of it working right every time. Im just avoiding bugs at this point. thanks in advanced for any of your thoughts!
I guess that as an alternative you can add a ".." at the end of the string ins$$anonymous$$d of getting a substring. ".." means "go back one directory in the file path", so:
c:\gameDirectory\game_data\..\
is the same as...
c:\gameDirectory\
Oh! I didn't even know that!!! It works flawlessly.
var dataloc : String = Application.dataPath + "//..//music//";
and it goes exactly where it should. fantastic thank you!
Your answer
