Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

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

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

  1. TheChuckster


    Dec 16, 2014
    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?


    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


    Jan 29, 2010
    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 :

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


    Nov 16, 2014
    Damn, please report those bugs!
  4. AnikKhoma


    Apr 10, 2014