Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by kityanlam3 · May 24, 2016 at 05:19 AM · c#modelwwwurl

Using WWW class to get multiple urls

I have several models (.obj) in my server and I want to get the URLs of all of them. I know in c# there's Directory.GetFiles but that's not usable, i also know WWW can get one of the models with a URL but I want all of them.

The models are stored inside a folder called Models, is there anyway to get all of their urls or something similar so that I can load them using an .obj loader.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image antx · May 24, 2016 at 06:38 AM 0
Share

can you not put an xml file or a txt file on the server which contains the urls of all the models?

Or use a something like a php script on the server which scans the folder and returns the file list upon requesting it via WWW class.

avatar image kityanlam3 antx · May 24, 2016 at 08:18 AM 0
Share

I'm not very good at server based coding, but I think the php script suits my needs, do you have any examples or links that I could go see how to go about doing?

Also my first time working with the WWW class :P

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by fafase · May 24, 2016 at 08:28 AM

Your best shot would be to download a json file from the server with all the urls you need to download.

As a result, your application only knows one url, for the json file. This also allows to modify the models without the need to ship a new version of the app.

 {
 "models":[ "models/modelA.obj", "models/modelB.obj",]
 }

 [Serializable]
 public class RootObject{
      public string [] models;
 }
 public class ParseJson:MonoBehaviour{
     string url = "http://myurl.com/"
     IEnumerator Start()
    {
         WWW www = new WWW(url+"data.json");
        yield return www;
        // Check if all valid
        RootObject ro = JsonUtility.Deserialize<RootObject>(www.text);
       foreach(string modelUrl in ro.models){
            WWW newWWW = new WWW(Path.Combine(url, modelUrl));
            yield return  www;
           // Continue with models and checking
      }
    }
 }


This is quite of a fastened version. The top is the json file that you download. It contains the two urls for two models. This is the file you would modify to add, remove models or other type of data.

Then the code simply reads the content to download the required assets.

The other way is AssetBundle:

http://docs.unity3d.com/Manual/AssetBundlesIntro.html

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image kityanlam3 · May 24, 2016 at 09:17 AM 0
Share

Yup I know about the assetbundle but doesn't suit the project. I think I can use your answer, I'll give it a shot and let you know. Thanks.

avatar image fafase kityanlam3 · May 24, 2016 at 12:00 PM 0
Share

As I mentioned, this is fairly quickly done and should benefit of a more modular pattern where download is handled in one class and the json somewhere. But that was just for the idea.

If you need more help, well, just ask.

avatar image
0

Answer by schashm3 · Apr 28, 2019 at 03:29 PM

zip your files and upload to your database and download the file zip in your app and unzip it...it's very simple... here is the unzip code... you must put the ZipFile.cs in your project and after that you get your zip file form url and just write ZipFile.Unzip(path,www.byte);

 public class unzip : MonoBehaviour{
 
 IEnumerator DownloadandUnzip(){
 
  UnityWebRequest www = UnityWebRequest.Get("yourURL.zip");
         yield return www.SendWebRequest();
         if (www.error!=null)
         {
             Debug.Log(www.error);
         }
         else
         {
             byte[] data = www.downloadHandler.data; 
             ZipFile.UnZip(Application.persistentDataPath, data);
         }
 }

this is the GitHub link for asset: https://github.com/kimsama/Unity-ZipDownload

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

149 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to assign texture from url 1 Answer

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How to download in the background using WWW class? 4 Answers

WWW with php file cannot sent more than 6 values ? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges