Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Getting urls from web server using WWW

Discussion in 'Scripting' started by kityanlam3, May 24, 2016.

  1. kityanlam3

    kityanlam3

    Joined:
    Feb 2, 2016
    Posts:
    41
    I know that for local files you can the c# Directory.GetFiles but what about for webservers? I have some .obj files stored inside a folder called models, I want to get the urls of all the models? Is it possible or will I have to manually input the url inside Unity?
     
  2. ericbegue

    ericbegue

    Joined:
    May 31, 2013
    Posts:
    1,353
    You need to know the urls beforehand or your server need to somehow provide the list of models (by scaning the folder on the server side).
     
  3. Patico

    Patico

    Joined:
    May 21, 2013
    Posts:
    886
    You should implement an endpoint on webserver for that. For example, when your call 'https://mywebserver.com/list-of-models.php' it would return a list of all existing urls.
    This way is better than hardcodings urls on client, because your url list can be changed.
     
    Kiwasi likes this.
  4. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    Kiwasi likes this.
  5. kityanlam3

    kityanlam3

    Joined:
    Feb 2, 2016
    Posts:
    41
    Sorry, I'm not very good at webserver side stuff. Could you explain what's an endpoint and how I go about doing that? This is my first time doing a game that needs webserver. @Patico
     
  6. Patico

    Patico

    Joined:
    May 21, 2013
    Posts:
    886
    Ok, could you share details/configuration of your server? What OS, webserver app, hosting do you use? Probably I can help you with it.