Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Other Assets\menu_maneger.cs(10,31): error CS1519: Invalid token ';' in class, record, struct, or interfac

Discussion in 'Scripting' started by pgood0586, Nov 22, 2022.

  1. pgood0586

    pgood0586

    Joined:
    Oct 23, 2022
    Posts:
    46
    Hello, I died in making a game. I made a way to make levels from a video tutorial, but now I have to add the number of levels in the menu general option, but when I wrote the script to show me the option to put levels in it, these two errors appeared and I tried to solve them, I did not know
    And also in Visual Studio there are 5 errors + there is a problem that the menu does not appear sometimes and there are menus that do not appear when I enter it, but I will leave these problems after solving the script
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class menu_maneger : MonoBehaviour
    6. {
    7.     public GameObject menu_panel;
    8.     public GameObject levels_panel;
    9.  
    10.     public GameObject() levels;
    11.  
    12.     int maxium_level = 1;
    13.  
    14.     // Start is called before the first frame update
    15.     void Start()
    16.     {
    17.         if (PlayerPrefs.HasKey("max_level")) {
    18.             maxium_level = PlayerPrefs.GetInt("max_level");
    19.         }
    20.         else {
    21.             PlayerPrefs.SetInt("maxlevel", 1);
    22.         }
    23.  
    24.         for (int i=1; i<=maxium_level; i++) {
    25.             if (i <= maxium_level) {
    26.                 // THIS LEVEL IS UNLOCKED
    27.                 Debug.Log("level " + i + " IS UNLOCKED");
    28.             }
    29.             else {
    30.                 // THIS LEVEL IS LOCKED
    31.                 Debug.Log("level " + i + " IS LOCKED");
    32.  
    33.             }
    34.  
    35.  
    36.        
    37.         }
    38.  
    39.     }
    40.  
    41.     // Update is called once per frame
    42.     void Update()
    43.     {
    44.        
    45.     }
    46.  
    47.     public void Showlevels() {
    48.     levels_panel.SetActive(true);
    49.      menu_panel.SetActive(false);
    50.     }
    51.  
    52.  
    53. public void ShowMenu() {
    54.      levels_panel.SetActive(false);
    55.      menu_panel.SetActive(true);
    56.     }
    57. }
    58.  
    I hope tell me if there is something I forgot to say + the script is not complete I wanted to solve this problem first and then complete it and it is supposed to open the stages and leave the other stages closed and remove the lock mark and save the player’s progress and be able to play in the stages I finished
     
  2. Strafe_m

    Strafe_m

    Joined:
    Oct 24, 2022
    Posts:
    72
    you use [] for a list not ()