1. We've introduced thread tags, search within a thread and similar thread search. Read more here.
    Dismiss Notice
  2. We've released our first Timeline Experimental Preview, our new tool for creating cutscenes and more! To check it out click here.
    Dismiss Notice
  3. All Unity Pro perpetual license customers: your special offer to subscribe is ready! Click here.
    Dismiss Notice
  4. Unity 5.5 is now released.
    Dismiss Notice
  5. Check out all the fixes for 5.5 in patch releases 1 & 2.
    Dismiss Notice
  6. Unity 5.6 beta is now available for download.
    Dismiss Notice
  7. Get prepared for the Tizen Mobile App Incentive Program! Read more about the upcoming program here.
    Dismiss Notice
  8. Enter the Microsoft Developer Challenge for a chance to win prizes. Read more about it here.
    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
    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:
    30,872
    "Using" is C#. You want "import".

    --Eric
     
  3. actionthom

    actionthom

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