Application.dataPath slightly bizzar

Web player: The absolute url to the player data file folder (without the actual data file name)

Ok that is what the reference says, however, this is not the case per say, you see, I have virtual paths setup and sub sites setup, when I use the Application.dataPath it returns to me the parent URL, not the subsite URL or sub folder… now I though this was odd, so I said fine, let me use System.IO and pull the Path.GetFullPath(“.”) well that returned to me on my Windows box “C:\Program Files\Unity\Web….…ocx”… I was like hmmm.

The player data file is located
http://www.gamedevonline.com/unity/arena.html

Now, on a MAC that System.IO returns just plain //Data/, what I need is the physical path on the web server not of the root folder but of the folder that contains the Arena.unity3d file, now I know what it is because i put it there, but I have not found a command in Unity that returns to me the true path to the file. On my hosted servers I create a folder and give this folder special permissions for the program and code it as such so that the program has rights to read and write to that folder as if it was a user on the machine.

Since Unity doesn’t have a way to pull this path (and it shifts depending on which server I am using, thus hard coding the path is not an option), how can I use the internal dataPath since it is not coded as the docs say it is coded? Is there another undocumented option in Unity that I am not aware of?

I can do this in ASPX easily enough, I can probably jury rig up some php to also do it, but I don’t want to have to pass that info back and forth to Unity, I want Unity to simply obtain this also and I though the Application.dataPath would be the solution, but it is not unfortunately. hmmm

The docs actually say that for a webplayer, Application.datapath returns the same thing as Application.absoluteurl, not the local filesystem path.

I imagine if it were to return a true application.datapath, it would either return the path to the browser or on windows the ocx file.

The web player can’t access the local filesystem anyway, so why does this matter?

Web player: The absolute url to the player data file folder (without the actual data file name)

That was my first line in the post, it says “to the player data file” but it is -not- to the player data file folder, it is to the website root path. So if you have folders and your data file is in that sub folder, it still only returns you to the absolute root url location, not the data file folder.

You can test this easily enough, create a sub folder on your web host, place your unity3d file in that folder with its reference html page, and see what you get with the path, you end up with the application root, not that folder… this is a delima.

I am not trying to access the “local” as in the user machine file system, I am trying to access the web root path folder which can be obtained with server side coding using php or asp, or asp.net for example, given the fact that the web player is installed on the local machine somewhere, it seems to be using public objects from the web server that ‘hosted’ it, which I find to be interesting.

I thought that the ocx was in the web cache folder, but it is not, it is in a local folder on the machine like a normal application and outside of the web security space. Found that out tonight, which is a little disturbing, and yes, through certain configurations because of where it sits, the web app would be able to access other folders since it is not in the limited cache folders.

That a side, the docs are just misleading in how they state the dataPath is, unfortunately for me I have to find a way to just dance around this, Application.dataPath for something that exists in a sub folder is the parent web url without that folder.

I have proven this, maybe the docs just need updated, I know this thing is not a bug, I realized what they are doing to get that path, I just need to figure out where they imbed that information. It is part of the command line argument to the ocx, at the time they download the unity3d file, they are capturing that referenced url parent path (not child with sub folders), and they pass that information back to the ocx when they launch the game to make it available.

That is just a parameter they use, like you start any program that allows for optional parameters, same difference here. The question is how to get the children subfolders to be part of that ocx path parameter. That is the issue. What I need access to is the virtual path that is writable on the server and limit it to just that single Unity application. Unfortunately for me the server farm was setup bizzar so that the network SAN only has certain servers per SAN and 3 different SANS and the folder structure is slightly different. More my problem than anything, I just don’t want to have to deal with another farm setup and have to find the pathing to hard code it again.

If the docs were right it wouldn’t have been an issue, could use the Application.dataPath as is + data folder path, now I have to deal with dancing through folders to get to the application root then data folder path.

I don’t quite follow, but it seems you’re confused about Unity’s awareness as a client-side application. It has no knowledge of where it came from on the server, only which URL it is publicly available from.

Hmmm not realy, I’ll post more with code tonight so you can see what I mean. This is harder for me to explain.

A unity webplayer cannot discover anything about the file structure of your server, unless you add something that is executed server-side to allow it to do so.

What you’d need is a server-side script which responds to requests from your webplayer (which is executing on the client computer), which reveals whatever information you want the webplayer to have about your server.

I’ve used something similar to this, to allow a “3D viewer” app to get a list of files stored in a server-side directory. It required a server side script to parse the directory contents and output them as text. The webplayer requested this over HTTP, and recieved the text. It could then select which file to load.

hope this helps,

  • Ben

can provide any tutorials?