D
D
damir4ig2021-04-24 16:32:24
C++ / C#
damir4ig, 2021-04-24 16:32:24

Error in unit Type or namespace definition, or end-of-file expected?

ssets\Scripts\Main1.cs(52,1): error CS1022: Type or namespace definition, or end-of-file expected

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

public class Main : MonoBehaviour
{
    public Text ecocoinsText;
    public Text moneyText;
    public int ecocoins;
    public int money;
    public GameObject settingsPan;
    public GameObject music;
    public GameObject MusicButton;
    public Text MusicButtonText;
    public GameObject shopPan;
    public GameObject exchPan;
    

    public void shopPan_SH()
    {
        shopPan.SetActive(!shopPan.activeSelf);
    }

    public void exchPan_SH()
    { 
        exchPan.SetActive(!exchPan.activeSelf);
    }
       

    public void settingsPan_SH()
    {
        settingsPan.SetActive(!settingsPan.activeSelf);
    }

    public void ButtonClicked()
    {
        ecocoins += 1;
        ecocoinsText.text = "EcoCoins: " + ecocoins;
        moneyText.text = "Money: " + money;
    }

    public void MusicButtonCl()
    {
        music.SetActive(!music.activeSelf);
        MusicButtonText.text = "Музыка: ОТКЛ";
        if(music.activeSelf)
        {
            MusicButtonText.text = "Музыка: ВКЛ";
        }
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2021-04-24
@damir4ig

Here's something that's clearly stated crookedly.
It must have been methods.

public void shopPan_SH
    {
        shopPan.SetActive(!shopPan.activeSelf);
    }
 
    public void exchPan_SH
    {
        exchPan.SetActive(!exchPan.activeSelf);
    }

In your case, it seems that the editor should highlight in red the places where the code is written crookedly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question