Search Unity

Simple C# string concatenation throws JS syntax error in WebGL player

Discussion in 'Editor & General Support' started by TheChuckster, Apr 21, 2015.

  1. TheChuckster

    TheChuckster

    Joined:
    Dec 16, 2014
    Posts:
    28
    Using the WebGL player, I get a runtime syntax error when attempting to concatenate static strings. If the strings are non-static, then the there is no runtime error and the correct result gets logged. Using String.Concat didn't work either -- same error. All this time, everything works just fine in the Unity editor.

    Is there a way to look at the intermediate output of IL2CPP?

    Repro:

    using UnityEngine;
    using System;
    using System.Collections;

    public class SceneSetup : MonoBehaviour {
    public static string a = "a";
    public static string b = "b";

    void Start()
    {
    Debug.Log (a + b);
    }
     
  2. nawash

    nawash

    Joined:
    Jan 29, 2010
    Posts:
    166
    Hi all,
    I got pretty much the same problem but in worse : string concatenation does not work even if the string are not static.
    Testing stuff I cam to this code that does not work.
    See the javascript console output below...

    Please help...

    string basepath = @"StreamingAssets/Models/";
    string asseturl1 = string.Copy(Application.absoluteURL);
    char[] jimcarray = asseturl1.ToCharArray();
    string asseturl = new string(jimcarray);
    string asseturl4 = string.Concat(asseturl, basepath);
    string asseturl5 = string.Concat(asseturl4, m_AssetName);
    Debug.Log("asseturl :" + asseturl5);

    Console output :
    asseturl :http://192.168.1.8/correctpath/

    the concatenation does not work at all, whatever strange workaround I use... any hint, someone ?
     
  3. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,905
    Damn, please report those bugs!
     
  4. AnikKhoma

    AnikKhoma

    Joined:
    Apr 10, 2014
    Posts:
    10