Unity Game CS1002 Problem

How do I solve it?

Assets\SettingsManager.cs(33,36): error CS1002: ; expected

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.IO;

public class SettingsManager : MonoBehaviour
{
    public Toggle _tamEkran;
    public Dropdown _cozunurluk;
 
    public Button uygulaButton;
 
    public Resolution[] cozunurluk;
    public GameSettings gameSettings;
 
 
 
    // Start is called before the first frame update
    void Start()
    {
    
    }

    // Update is called once per frame
    void Update()
    {
    
    }
 
    void OnEnable()
    {
        gameSettings = new GameSettings()
    
        _tamEkran.onValueChanged.AddListener(delegate { onTamEkranToggle(); });
        _cozunurluk.onValueChanged.AddListener(delegate { onCozunurlukDeistir(); });
    
        cozunurluk = Screen.resolutions;
    
        foreach(Resolution res in cozunurluk)
        {
            _cozunurluk.options.Add(new Dropdown.OptionData(res.ToString()));
        }
    
        LoadSettings();
    
    }
 
    public void onApplyButton()
    {
        SaveSettings();
    }
 
    public void onTamEkranToggle()
    {
        gameSettings.tamEkran = Screen.fullScreen = _tamEkran.isOn;
    }
 
    public void onCozunurlukDeistir()
    {
        Screen.SetResolution(cozunurluk[_cozunurluk.value].width, cozunurluk[_cozunurluk.value].height, Screen.fullScreen);
    }
 
 
    public void SaveSetting()
    {
       string jsonData = JsonUtility.ToJson(GameSettings,true);
       File.WriteAllText(Application.persistenDataPath +"/OyunAyarlariGameSettings.json", jsonData);
    }
 
    public void LoadSettings()
    {
        GameSettings = JsonUtility.FromJson<GameSettings>(File.ReadAllText(Application.persistentDataPath + "/OyunAyarlariGameSettings.json"));
    
        _tamEkran.isOn = GameSettings.tamEkran;
        _cozunurluk.value = GameSettings.cozunurlukIndexx;
    }
}

[/ Code]

Exactly what the error says. It misses a ; in line 33 at the 36th character.
Since you posted your code starting at line 2, t’s at the end of line 34 in the snippet you posted.
gameSettings = new GameSettings();

When you do so, there are 12 errors

Then you need to solve those as well.
Only ever look at the first error. All other errors can simply be caused by the first one.

So what is your first new error?

1 Like

One fundamental thing you need to learn about compiling code: getting a higher number of compile errors does NOT mean you have moved further from the correct solution.

When you didn’t have the semicolon there, the compiler couldn’t even make sense of the structure of your script file. So it just told you “Here’s this problem, but that’s as far as I can get”. Now you fix that problem, now the compiler understands more about your code, so it can tell more things that are wrong with it, and reports all of them.

Imagine the compiler like a home inspector. If your home’s front door is broken and can’t open, the inspector will tell you one thing is wrong: the door is broken. You fix that, send the inspector in, and now he can tell you 12 thigns are wrong: your shoddy wiring, your moldy ceiling, etc etc. Those problems were all there no matter what, it’s just that now the home inspector is able to find them and tell you about them.

3 Likes