I know this is stupid easy…but I simply cannot get this to work and it is driving me bonkers. I was using the online documentation, but the syntax being provided for the commands (hopefully i found the right ones!) is generating errors…
Basically, I have SceneA, which contains Button1.
When I clock Button1 i want to go to SceneB
I find PLENTY of support for Application.LoadLevel but it seems that this is “obsolete” with the version im using (5.3) and ii need to use the SceneManager context…but I am just going in a circle of errors trying to figure out how to do get this working…
Here’s a script you can attach to a game object and link to the button:
using UnityEngine;
using UnityEngine.SceneManagement;
public class Control : MonoBehaviour
{
public void NextScene()
{
SceneManager.LoadScene("Blank");
}
}
Thank you for that speedy reply and MUCH simplified script compared to the beast i had written…(i am an ABSOLUTE beginner, I warn you now…)
So, i have taken your script, and simply replaced the text of mine with yours.
My script is listed as an “Asset”.
I went to my button, down to the On Click() area…
I have it set to “Editor and Runtime”
then below that, the “Asset”, “Test_Script” has been selected.
And the pulldown on the right is set to “No Function”
But when i try to test my button…i see it press down and then release…but no action takes place.
my script needs to be named Control? when I try to do that i get an error:
The namespace ‘global::’ already contains a definition for ‘Control’
and when i try to drop my script, “MyTestScript” on the game object i created (and renamed ‘Controller’), i get the error:
Can’t add script component ‘MyTestScript’ because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match…
you know…i have no idea. i was doing a lot of stuff messing around trying to self teach myself this. i think i may best off scrapping my playground and starting fresh.