Search Unity

testing Unity 5 WebGL using javascript - giving code errors

Discussion in 'Editor & General Support' started by programicks, Apr 15, 2015.

  1. programicks

    programicks

    Joined:
    Sep 5, 2014
    Posts:
    11
    Hi.

    I am testing webGL in Unity 5 and have been writing in javascript since Unity 4.
    When, in Unity 5, I set to web player and publish, I get no errors in code but when I publish to webGL, it's telling me I need to fix compiler errors.

    I was wondering the reason for this.

    Cheers.
     
  2. soloneer

    soloneer

    Joined:
    Nov 23, 2010
    Posts:
    62
    What are the errors? I've had various issues with WebGL builds, some things environmental (Antivirus not liking it) to project specific issues (upgrades from 4 not going well).
     
  3. programicks

    programicks

    Joined:
    Sep 5, 2014
    Posts:
    11
    Hi. Well, one of the errors I am getting is BCE0019: 'enabled' is not a member of 'UnityEngine.Component'
    for the line,
    vcmaa2__antenna__m1.GetComponent('2_antennas_m').enabled = true; which is a script connected to an object where I enable a script.
    But it's just, the whole idea of me using Unity is so I can write my code once and publish to anywhere. While the web player is still around, I want to be able to write javascript for that and know that the same javascript will work in webGL.
    At the moment, I will have to have 'one' way of writing javascript for the web player and 'another' for webGL since, it lets me publish with no errors for the web player but gives me errors for webGL.

    I think I might find a way of contacting the staff of Unity to ask them why it does this. I really want to support Unity as I like the concept but this defeats the objective. I appreciate you responding though darkmobius.
     
  4. soloneer

    soloneer

    Joined:
    Nov 23, 2010
    Posts:
    62
    Don't use a string in GetComponent, that returns type Component which does not have the enabled property.Make it just the script/class type (no quote marks).
    It might be the webplayer build wasn't being as strict, remember WebGL is currently "preview". In any case it looks like the code isn't strictly quite right in the first place.