Search Unity

Errors on Game Manager script

Discussion in 'Scripting' started by MaskyDEV, Nov 26, 2014.

  1. MaskyDEV

    MaskyDEV

    Joined:
    Nov 16, 2014
    Posts:
    10
    I am using a script by TheFaceGrabber; here's the errors and script.
    assets/Scripts/GameManager.cs(25,9): error CS1525: Unexpected symbol `}'
    Assets/Scripts/GameManager.cs(34,28): error CS1519: Unexpected symbol `else' in class, struct, or interface member declaration
    Assets/Scripts/GameManager.cs(36,39): error CS1519: Unexpected symbol `=' in class, struct, or interface member declaration
    Assets/Scripts/GameManager.cs(38,17): error CS0178: Invalid rank specifier: expected `,' or `]'
    Assets/Scripts/GameManager.cs(38,47): error CS8025: Parsing error
    NOTE: I already tried multiple ways to fix this and I couldn't see any problems
    Script:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4.  
    5.     public class GameManager : MonoBehaviour {
    6.     public List<Character> Characters = new List<Character>();
    7.     bool ShowCharWheel;
    8.     public int SelectedCharacter;
    9.     int LastCharacter;
    10.     public static GameManager Instance;
    11.  
    12.     void Awake()
    13.     {
    14.  
    15.     }
    16.     // Use this for initialization
    17.     void Start ()
    18.     {
    19.         Instance = this;
    20.         foreach (Character c in Characters)
    21.         {
    22.             c.Instance = Instantiate (c.PlayerPrefab, c.HomeSpawn.position, c.HomeSpawn.rotation) as GameObject;
    23.         }
    24.         ChangeCharacter (Characters [0])
    25.     }
    26.    
    27.     // Update is called once per frame
    28.     void Update ()
    29.     {
    30.         if (Input.GetKey (KeyCode.C))
    31.         {
    32.             ShowCharWheel = true;
    33.         }
    34.             else
    35.         {
    36.             ShowCharWheel = false;
    37.         }
    38.         Characters [SelectedCharacter].Instance.GetComponent<PlayerController> ().CanPlay = true;
    39.         Camera.main.GetComponent<SmoothFollow> ().target = Characters[SelectedCharacter].Instance.transform;
    40.    
    41.     }
    42.  
    43.     void ChangeCharacter(Character c)
    44.     {
    45.         SequenceManager.Instance.StartCoroutine ("DoCharSwitch", c);
    46.         LastCharacter = SelectedCharacter;
    47.         SelectedCharacter = Characters.IndexOf (c);
    48.         Characters [LastCharacter].Instance.GetComponent<PlayerController> ().CanPlay = false;
    49.         Characters [SelectedCharacter].Instance.GetComponent<PlayerController> ().CanPlay = true;
    50.         Camera.main.GetComponent<SmoothFollow> ().target = Characters[SelectedCharacter].Instance.transform;
    51.     }
    52.  
    53.     void OnGUI()
    54.     {
    55.         if (ShowCharWheel)
    56.         {
    57.             GUILayout.BeginArea(new Rect(Screen.width-64, Screen.height-192,64,192));
    58.             foreach(Character c in Characters)
    59.             {
    60.                 if(GUILayout.Button(c.Icon,GUILayout.Width(64),GUILayout.Height(64)))
    61.                 {
    62.                     ChangeCharacter(c);
    63.                 }
    64.             }
    65.             GUILayout.EndArea();
    66.         }
    67.     }
    68. }
    69.  
    70. [System.Serializable]
    71. public class Character
    72. {
    73.     public string Name;
    74.     public Texture2D Icon;
    75.     public GameObject PlayerPrefab;
    76.     public GameObject Instance;
    77.     public Transform HomeSpawn;
    78. }
     
  2. Stoven

    Stoven

    Joined:
    Jul 28, 2014
    Posts:
    171
    You forgot to put a semicolon after the function call 'ChangeCharacter(Characters[0])'
     
  3. MaskyDEV

    MaskyDEV

    Joined:
    Nov 16, 2014
    Posts:
    10
    THANK YOU