Search Unity

  1. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  2. Scriptable Render Pipeline improvements, Texture Mipmap Streaming, and more! Check out what we have in store for you in the 2018.2 Beta.
    Dismiss Notice
  3. If you couldn't join the live stream, take a peek at what you missed.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  5. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  6. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  7. 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

    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:
    144
    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. Thrawn75

    Thrawn75

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

    AnikKhoma

    Joined:
    Apr 10, 2014
    Posts:
    10