using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class start : MonoBehaviour
{
public void StartGame()
{
SceenManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}
9002053–1240324–unity help.cs (283 Bytes)
there are a error how can i fix this?
You’ve spelled “Scene” wrong. Look at the error, it’s saying there’s no such thing as “Sceen” Manager.
Beside that basic spelling mistake:
- Class and Type names should always start with a capital letter.
- You should not call your class like a common method or like another common class. This just calls for trouble
- Finally this class does nothing besides creating this “StartGame” method. Is that called by a UI button where you linked this method to the OnClick event? If not this class wouldn’t do anything at all. Though I guess loading that scene was the main intention?
If this is just meant as an “action” that can be linked to a button or some other UnityEvent, you could make this class way more versatile this way:
using UnityEngine;
using UnityEngine.SceneManagement;
public class SceneLoader : MonoBehaviour
{
public void LoadScene(int aSceneIndex)
{
SceenManager.LoadScene(aSceneIndex);
}
public void LoadNextScene()
{
LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}
This way you could either bind a button to LoadScene and specify the actual scene index in the UnityEvent, or call LoadNextScene which simply loads the next scene. Of course you could think of some other useful methods that could be added so the script could be used for various scene loading tasks.
Hello Bunny 83
i check the code out bbuuut now there is:
Assets\starteasy.cs(7,13): error CS0103: The name ‘SceenManager’ does not exist in the current context
Did you read the part where I said you spelled “Scene” wrong? It’s “SceneManager”. 
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceenManagement;
public class start : MonoBehaviour
{
public void StartGame()
{
SceenManager.LoadScene(SceenManager.GetActiveScene().buildIndex + 1);
}
}
Assets\starteasy.cs(4,19): error CS0234: The type or namespace name ‘SceenManagement’ does not exist in the namespace ‘UnityEngine’ (are you missing an assembly reference?)
i wride Sceen at every word i wride scene before
Just spell it correctly.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class start : MonoBehaviour
{
public void StartGame()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}
i make everything you say to me but its still not working
Sorry to waste your time
but the error
Assets\starteasy.cs(4,23): error CS0234: The type or namespace name ‘SceenManagement’ does not exist in the namespace ‘UnityEngine’ (are you missing an assembly reference?)
comes
ok i discribe the situation
i have my button and the scrip componnent.
i can start the game but it not work about: look up
i want it on on click but under the script: The assiacted script can not be loaded. Please fix any compile errors and assign a valid script.
i watch a totorial and on click isn,t no funktoin an under monoscript there much more.
thx if you can help me
The class name and the file name that contains that class have to match. You called your class “start” while the name of the file is “starteasy”. This doesn’t work. I already said that “start” is a really bad name for a class. So I highly recommend to rename it to something meaningful. Also make sure that whatever you want to call your class, keep the name of the file always in sync.
oh man :
InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings.
UnityEngine.Input.get_mousePosition () (at <46da9ce57a644141b0e40d2e12db7dd5>:0)
UnityEngine.EventSystems.BaseInput.get_mousePosition () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/BaseInput.cs:75)
UnityEngine.EventSystems.StandaloneInputModule.UpdateModule () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:178)
UnityEngine.EventSystems.EventSystem.TickModules () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:452)
UnityEngine.EventSystems.EventSystem.Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:467)
does i must delete the event systeme?