Hi there! Me and my friend have made a dot game so when the red one is clicked the game loads lvl : Main Menu and when a blue dot is clicked it loads the next level.So far i got 2 levels so everything works fine but how do i add on the same object another script so when it is clicked it loads the next lvl?Because here is my code :
You could try using something like:
Let me know if this works as im not certain.
using UnityEngine;
using System.Collections;
public class LoadNextLevel : MonoBehaviour
{
public int CurrentlyLoadedLevel;
void Awake()
{
CurrentlyLoadedLevel = Application.loadedlevel;
}
void OnMouseDown()
{
Application.LoadLevel (CurrentlyLoadedLevel + 1);
}
}
If it’s all 2d stuff just add some buttons to them. Then add the button functions like this
public void StartLevel1()
{
Application.LoadLevel("LevelName")
}
public void StartLevel2()
{
Application.LoadLevel("LevelName")
}
public void StartLevel3()
{
Application.LoadLevel("LevelName")
}
Then put it on a empty gameobject on every scene, link the buttons up. However don’t use this in a actual game cause it’s really easy to hack and people would just skip through the game. That’s where button listeners come in pretty good.