Unity Community


Results 1 to 3 of 3

  1. Posts
    6

    Using system.Collections.Generic; claims there's no semi-colon and makes me sad

    Hello!

    I'm trying to create a script (Javascript) for accepting user input for player names on a team and then cycling through that list to make a series of buttons with their names on.
    I decided to use a Generic List for this after following the advice of this blog: http://robotduck.wordpress.com/2009/11/04/88/

    However, whenever I add the line 'using System.collections.Generic;' to the top of my script, it displays '';' expected. Insert semicolon at the end. (UCE0001)'.
    But it has a semicolon at the end
    It must be something else, but my debugging is woeful as I'm still quite the beginner.

    Any tips on why this might be?

    My script is as follows:

    Code:  
    1. #pragma strict
    2.  
    3. using System.Collections.Generic;
    4.  
    5. var teamEntry = true;
    6. var teamEntryString : String = "Team Name";
    7. var teamName = "teamName";
    8. var playerEntry = false;
    9. var playerEntryString : String = "Player Name";
    10. var playerName = "playerName";
    11. var playerList = new List.<String>();
    12. var lineSelect = false;
    13. var buttonSize = 30;
    14.  
    15. function Start() {
    16.  
    17. }
    18.  
    19. function OnGUI(){
    20.     if (teamEntry) {
    21.         teamEntryString = GUI.TextField( Rect(25,25,100,20), teamEntryString);
    22.         if(GUI.Button (Rect(25, 60, 100, 30), "Accept")){
    23.             teamName = teamEntryString;
    24.             teamEntry = false;
    25.             playerEntry = true;
    26.            
    27.         }
    28.     }
    29.     if (playerEntry) {
    30.         playerEntryString = GUI.TextField( Rect(25,25,100,20), playerEntryString);
    31.         if(GUI.Button (Rect(25, 60, 100, 30), "Add Player")){
    32.             playerList.Push ( playerEntryString );
    33.         }
    34.         if(GUI.Button (Rect(25, 90, 100, 30), "Finish")){
    35.             playerEntry = false;
    36.             lineSelect = true;
    37.         }
    38.     }
    39.     if (lineSelect) {
    40.         for (var i=0; i < playerList.length; i++) {
    41.                 if(GUI.Button (Rect(25, (i * buttonSize), 100, 20), playerList[i] )){
    42.             }
    43.         }
    44.     }
    45. }
    46.  
    47.  
    48. function Update() {
    49.    
    50. }

  2. Volunteer Moderator
    Posts
    23,719
    "Using" is C#. You want "import".

    --Eric
    SpriteTile: new tile system that works seamlessly with Unity 4.3 sprites
    FlyingText3D: dynamic 3D text with TTF fonts | Vectrosity: fast & easy line drawing
    Nifty utilities! Stitch terrains together - runtime model importing - file browser - fractal landscapes


  3. Posts
    6
    You beast! That is amazing!
    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •