1. Unity 5.6 is now released.
    Dismiss Notice
  2. We've introduced thread tags, search within a thread and similar thread search. Read more here.
    Dismiss Notice
  3. Learn how you'll soon be able to publish your games to China in four simple steps with Xiaomi. Sign up now for early access.
    Dismiss Notice
  4. Get further faster with the Unity Plus Accelerator Pack, free for new Unity Plus subscribers for a limited time. Click here for more details.
    Dismiss Notice
  5. The launcher is currently pulling earlier versions of the content packages which may have errors, see post.
    Dismiss Notice
  6. We've released our first Timeline Experimental Preview, our new tool for creating cutscenes and more! To check it out click here.
    Dismiss Notice
  7. Check out all the fixes for 5.5 in patch releases 1 & 2.
    Dismiss Notice

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
    Posts:
    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
    Posts:
    31,001
    "Using" is C#. You want "import".

    --Eric
     
  3. actionthom

    actionthom

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