Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

General script/syntax reference?

Discussion in 'Editor & General Support' started by Morgan, Jun 16, 2006.

  1. Morgan

    Morgan

    Joined:
    May 21, 2006
    Posts:
    1,223
    Some JavaScript statements don't seem to apply in Unity--where is a good place to find documentation of general scripting and syntax? Not the Unity-specific stuff like Transform etc., but documentation of conditions, loops, and those kinds of basics.

    I want to browse what can be done code-wise before I get in too deep. For instance, this JavaScript using case doesn't work in Unity, but I imagine Unity can do something similar:

    Code (csharp):
    1.  
    2. var n = 2; //any value
    3.  
    4. switch(n)
    5. {
    6. case 1:
    7.   //execute code block 1
    8.   break;
    9. case 2:
    10.   //execute code block 2
    11.   break;
    12. default:
    13.   //code to be executed if n neither
    14. }
    15.  
    What should I be looking for? Not documentation on JavaScript, which would allow the above. Should I be looking for a Mono beginner's guide?

    Where would a Unity scripting beginner go for reference on the basics?

    (I've done a lot of scripting over the years, even some JavaScript, but I am sure I could learn a lot from some kind of reference guide--as long as it has info that's true for Unity.)
     
  2. elias723

    elias723

    Joined:
    Feb 10, 2006
    Posts:
    178
    I've mostly been using the Unity reference to figure out how to code stuff, but when transferring my Java to JavaScript knowledge in the beginning I used regular JavaScript documentation. Some things just don't work, and I usually just asked about them on this forum to find an answer. For instance, changing an integer to a string is different from in JavaScript. I don't think there is a way to use switch case syntax with Unity. Perhaps you should look at Mono docs (I've never tried that), but most of the syntax is just the same as JavaScript. You should also take a look at Davey JJ's tutorials if you haven't already done so (racing and beginning). If you need any one specific problem you can't find an answer to, work around it for the moment and post your question on this forum. If anyone knows the answer it will be up within the next day or so.
     
  3. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Upgrade to Unity 1.5. It has switch statements in javascript now. Unity's javascript is a lot closer to ecma 2.0 JS now.
     
  4. Morgan

    Morgan

    Joined:
    May 21, 2006
    Posts:
    1,223
    Great--I'll stick with regular JS documentation then. Just my luck to try "switch" as one of my first experiments!

    U1.5 sounds great! I just noticed it was out. Nice new home page too!