Search Unity

Application.absolutURL web gl and constant text

Discussion in 'Web' started by perlohmann, Aug 24, 2015.

  1. perlohmann

    perlohmann

    Joined:
    Feb 12, 2009
    Posts:
    221
    Hi,

    So I have made a web gl build where everything works in the editor, but when I try to make an actual webgl local deployment and view it in in chrome (using these flags: "chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security --allow-file-access-from-files" (remember to fully close chrome from the task bar as well)), then the following code does not work.

    string test = "Some default value";
    string path = Application.absoluteURL.Replace("/index.html", "");
    test = path + "/xxx/yyy/zzz.jpg";
    Debug.Log(test);​

    This simply outputs the folder of the index.html file and does not add the second line to the path string (so yes the code compiles and "works", but not as you would expect). e.g. it prints out: "file:///C:/builds/webgl", but you would expect: "file:///C:/builds/webgl/xxx/yyy/zzz.jpg".

    I have tried using StringBuilder and String.Format, but both with the same result

    Do note that this is on a local file system and not hosted on a webserver. I have tried increasing the memory that is reserved for the webgl player in steps up to 1024mb, but no change. I have made the build in 5.1.2 and also tried 5.1.2.p3

    Edit: build mode fastest (slowest build) and with stripping disabled (full logging)
     
    Last edited: Aug 24, 2015
  2. perlohmann

    perlohmann

    Joined:
    Feb 12, 2009
    Posts:
    221
    a little addition. it did not work in an online version either.
     
  3. perlohmann

    perlohmann

    Joined:
    Feb 12, 2009
    Posts:
    221
    or in firefox =(
     
  4. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    We recently found a bug with how the string object for Application.absoluteUrl is written in WebGL, resulting in an invalid string object, which then fails to concatenate with other strings correctly. This bug is fixed, the fix will be in 5.3. Probably you can work around it by doing something like path = path.Substring(0, path.Length-1); until then.
     
  5. perlohmann

    perlohmann

    Joined:
    Feb 12, 2009
    Posts:
    221
    Thx Jonas,

    The "path = path.Substring(0, path.Length-1)" worked.