I’ve only been coding on Unity for 3 days and I have this problem where I am getting all these errors:
Assets\SceneChange.cs(25,1): error CS1022: Type or namespace definition, or end-of-file expected
Assets\SceneChange.cs(21,1): error CS0106: The modifier ‘public’ is not valid for this item
Assets\SceneChange.cs(21,1): error CS8803: Top-level statements must precede namespace and type declarations.
does anyone know how to fix them
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class SceneChange : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
public void ChangeScene()
{
SceneManager.LoadScene("Career Menu");
}
}
Seriously? Your previous topic was the exact same issue and you were told that the method was outside of your class.
If you still do not know what a class is, or why your methods need to be inside your class, then you really need to stop what you are doing and go off to work through a load of beginner C# tutorials.
Only once you are able to work in C# properly will you really be able to get further in writing Unity scripts (at least without having to come to the forum to ask the same question more times).
Sorry if this sounds harsh, but it is the reality that you are going to have to face. Programming is something that you have to be 100% accurate in, so you need that understanding first.