Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How do i fix this Unexpected Token error(JS)??

Discussion in 'Scripting' started by alexander11, Nov 1, 2016.

  1. alexander11

    alexander11

    Joined:
    Aug 11, 2014
    Posts:
    94
    Hello i have been getting into CSG, and i have found a CSG script on github i downloaded it, but i keep getting this error

    "Assets/Scripts/CSG/csg.js-master/csg.js(180,21): BCE0043: Unexpected token: +." does anyone know how to fix this???

    ( i have gone to the c# port but i don't want that one because it takes so long to generate i just only want this one or something that can generate fast)
     
  2. Hyblademin

    Hyblademin

    Joined:
    Oct 14, 2013
    Posts:
    725
    UnityScript is not the same as JavaScript, so some changes usually need to be made to scripts that weren't designed for Unity. Try removing the +'s that appear in the matrices around line 180. I don't think + is a valid unary operator in UnityScript.
     
  3. alexander11

    alexander11

    Joined:
    Aug 11, 2014
    Posts:
    94
  4. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    What do you mean when you say this?
     
  5. alexander11

    alexander11

    Joined:
    Aug 11, 2014
    Posts:
    94
    @KelsoMRK Download the script(in the post just follow the link) and you'll see, its something to do with an array.
     
  6. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Switching from C# to JS will have no effect on the performance of the code.
     
  7. alexander11

    alexander11

    Joined:
    Aug 11, 2014
    Posts:
    94
    @KelsoMRK its different CSG code, there will be an effect, this is one script not like the C# one where it has up to 7 scripts and in those scripts it uses a lot of lerps which is cost effective on performance.
     
  8. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    If you say so....
     
  9. alexander11

    alexander11

    Joined:
    Aug 11, 2014
    Posts:
    94
    Lol, anyway would you know how to fix this??
     
  10. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    The two languages compile to (roughly) identical IL so changing what the code is written in will literally do nothing. If you're trying to change the architecture of the solution then that's another thing. In that case I'd suggest using Unity's profiler to see exactly what is taking the most time and optimize those pieces of code.
     
  11. alexander11

    alexander11

    Joined:
    Aug 11, 2014
    Posts:
    94
    I could do that but that'd take a while since i'm not an expert at code, i just need someone who can convert the JS script in to Unitys JS.