Search Unity

WebGL WWW Load local resource failed

Discussion in 'Web' started by Handsome-Wisely, Nov 16, 2017.

  1. Handsome-Wisely

    Handsome-Wisely

    Joined:
    Mar 20, 2013
    Posts:
    102
    i use www to load a texture to my app. but when i release to webgl. load failed!
    my code like this:
    Code (CSharp):
    1. [QUOTE]
    2. IEnumerator IELoadTx()
    3.     {
    4.         WWW www = new WWW("file://d:/1.txt");
    5.         yield return www;
    6.         text = www.text;
    7.     }
    8. [/QUOTE]
    it is run ok in edit mode, but failed on webgl!
    why? who can tell me how to do?
     
  2. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    You can't access the local file system from a web page. You need to place your files in Streaming assets and build the path using https://docs.unity3d.com/ScriptReference/Application-streamingAssetsPath.html
     
  3. Handsome-Wisely

    Handsome-Wisely

    Joined:
    Mar 20, 2013
    Posts:
    102
    thank you! I find the answer, use blob path can access local file.
     
  4. Aiursrage2k

    Aiursrage2k

    Joined:
    Nov 1, 2009
    Posts:
    4,835
    well i can access the local files in microsoft edge browser