Changing scene by clicking on a game object
Hello everyone, firstly I apologize for my basic question, I'm a begginer with programming and can't get to make this simple action! I have a scene in which I placed four objects, and I want to change to a different scene every time the user presses a game object. I got to do it without a problem by pressing different keys, but when I want to do it by clicking on the objects I get really lost. I tried creating an int that changes value when the user presses the object, but I'm having problems accesing that int from another script. Maybe there is a simple way and I'm not realising it.. This is the code I used for changing scenes with the keyboard:
using UnityEngine;
using System.Collections;
public class SceneManager : MonoBehaviour
{
static SceneManager Instance;
void Start()
{
if (Instance != null)
{
GameObject.Destroy(gameObject);
}
else
{
GameObject.DontDestroyOnLoad(gameObject);
Instance = this;
}
}
void Update()
{
if (Input.GetKeyUp(KeyCode.UpArrow))
{
Application.LoadLevel("2");
}
if (Input.GetKeyUp(KeyCode.DownArrow))
{
Application.LoadLevel("Demo");
}
}
}
Thank you in advance!
Answer by EDZVR · Jun 25, 2017 at 04:56 PM
I am trying to do the same thing!! Did you find out how to do this??
Your answer
Follow this Question
Related Questions
Unet Online Scene Selector, Choose from multiple maps, etc. 2 Answers
Change scene on collision C# 2 Answers
Companion spawns in default place instead of behind Player 1 Answer
Toogle Parent to Camera Function - Google Cardboard 0 Answers
Using a reference for another script in a method issue. 0 Answers