1. Submit bugs to enter our 5.4 Beta Sweepstakes. Read more about it here.
  2. Unity 5.4 public beta is now available for all users. Grab the build and visit the 5.4 beta forum.
  3. Missing a module? More about the new installer in 5.3 here.
  4. 4.7.1 released for Xcode 7.3 support. Thread here.

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

Discussion in 'Scripting' started by actionthom, Jun 26, 2012.

  1. actionthom

    actionthom

    Joined:
    Jun 26, 2012
    Messages:
    6
    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 (csharp):
    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. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Messages:
    29,666
    "Using" is C#. You want "import".

    --Eric
     
  3. actionthom

    actionthom

    Joined:
    Jun 26, 2012
    Messages:
    6
    You beast! That is amazing!
    Thanks :D