using www class to receive list of folders on webspace.

Hi there,

Currently working on a small university project creating a visualisation application for 3D.

I have most functionality working although when querying the applications use via webplayer , allowing users to upload their own 3D models to view has got me stuck.

currently have an array

var custom: String[ ];

using this I was able to create a list of all folders found within the custom array variable.

custom = Directory.GetDirectories(Application.dataPath + “/Models”);

Now I am using webplayer in order to do this I believe I need to use the WWW Class found within unity as the System.IO utilities do not work.

Messing about I have come up with this solution although not having any luck

var www:WWW = new WWW(" Application.dataPath + “/Models”);

yield www;

custom.add(www);

I am aware that I cannot create extra folders on startup so am not using

System.IO.Directory.CreateDirectory(Application.dataPath+“/Models”);

which was in place before to create that directory on startup for an offline built.

At the minute I have a .html .unity3d file along with a models folder stored on google drive space although am having no luck trying to achieve my end goal.

If anyone could help me would be much appreciated and if you could offer an alternative method to create a folder within the webspace on startup would be great.

Thankyou,

Andrew

You might want to look at this:

http://docs.unity3d.com/Documentation/Manual/UnityWebPlayerandbrowsercommunication.html

You could essentially write a script on your webspace that could do the folder work (Should be pretty easy to do), call it from Unity using ExertnalCall, and have it pass the relevant data back into Unity via the webplayer SendMessage()

awesome, thanks for the fast reply.

will take a look into this today and let the thread know how I get on!

thanks again,

Andrew.

so far I have:

Application.ExternalCall (“CreateFolders”, Application.dataPath + “/Backgrounds”);

This line within my unity.js file calling the function CreateFolders within the html, this is functioning correctly and giving me an alert with the correct path the folder should be created with.

Here is the script within the .html file firing off:

this is creating a message upon startup although not sure the folder creation bit is correct.

@Cesare, I think you need to think this through a little more carefully. A web browser running on your machine is really just a viewer that shows content fetched from a remote server. So, right at the moment, I have a web browser viewing the forum. All the data I am looking at is coming from the server. There’s nothing coming from my machine. I’m obviously writing some text here, which will get pushed to the server. The text I write doesn’t live on my hard drive. Once I hit post button, the text will get uploaded to the server, where it’ll be stored in a database and displayed when people view this thread.

In your case, you’d typically use the http POST to upload model data to your web server. (You do have a web server right?) Ideally this model data would be asset bundles, in which case your users can then fetch this data from your server using the WWW class and have the data in the app. This data might or might nor be stored locally. Use the LoadFromCacheOrDownload API if you want the models stored locally.

Under no circumstances should you expect the web player to have any access to the hard drive of the machine where it is running. That would be a huge security risk - how would you know that the web player you are fetching from your server isn’t swapped out for a player that simply deletes all the files on your hard drive? If you want your application to have access to the hard drive, then it needs to be a standalone application.

Thankyou Graham,

In the correct circumstances i’d like to have two temp folders stored alongside my .html and .unity3D files initiated at runtime in the webspace. The plan for these folders is so users can upload and load custom models/backgrounds from, that was my query.

Obviously to upload these local files onto webspace it would be required to use the WWW class, although before sorting out this functionality I believed it more important to make sure the getDirectories operator was working as to not rend everything previously created obsolete.

But a great help with some of the things explained. I guess I can use the http POST method to upload model data to these specific folders which I will just manually create to begin with and then can work from there.

Very new to this apologies for misinterpreting what I am trying to achieve, and thanks.

Andrew

edit:

In relation to my webserver, I am currently using google drive in its place and have had no issues so far with that.

Asset bundles are they not created within unity itself, if the user was required to load unity everytime they wanted to import a model it would make my application kind of irrelevant, I am using the objImporter script to get these working atm so all I really need is a .obj and .mtl file.