- Home /
cant loadlevel on C#
using UnityEngine; using System.Collections;
public class MainMenu : MonoBehaviour {
private string InstructionText = "Instructions:\nPress Left and Right Arrows to move.\nPress Spacebar to fire.";
private int ButtonWidth = 200;
private int ButtonHeight = 50;
void OnGUI()
{
GUI.Label(new Rect(10, 10, 200, 200), InstructionText);
if (GUI.Button(new Rect(10, 30, 200, 200), "Start Game"))
{
//###########THIS IS THE LINE I HAVING PROBLEM ################
Application.loadedLevel(1);
}
}
}
UNITY GIVE ME THIS ERROR
Assets/Scrips/MainMenu.cs(15,25): error CS1955: The member UnityEngine.Application.loadedLevel cannot be used as method or delegate
Answer by Seth-Bergman · Nov 09, 2012 at 05:18 AM
it's
Application.LoadLevel(1);
http://docs.unity3d.com/Documentation/ScriptReference/Application.LoadLevel.html
Answer by harschell · Nov 23, 2012 at 06:03 AM
@killaweed You wrote Application.load*ed*Level(1); It always shoud be `Application.LoadLevel(1);`
using UnityEngine;
using System.Collections;
public class MainMenu : MonoBehaviour
{
private string InstructionText = "Instructions:\nPress Left and Right Arrows to move.\nPress Spacebar to fire.";
private int ButtonWidth = 200;
private int ButtonHeight = 50;
void OnGUI()
{
GUI.Label(new Rect(10, 10, 200, 200), InstructionText);
if (GUI.Button(new Rect(10, 30, 200, 200), "Start Game"))
{
//#Corrected Code
Application.LoadLevel(1);
}
}
}
Hey @killaweed Cheers & Do accept The Answer
Answer by DeveshPandey · Nov 23, 2012 at 11:58 AM
There are difference between
Application.LoadLevel(1) - This is a method. This will load scene no.1
Application.LoadedLevel - This is not a method. This returns loaded scene (int)
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Follow-up from previous question: "Load levels randomly" 0 Answers
Opening a level when dead 2 Answers
how can i load a scene when reaching certain score? Roll-a-Ball Project 1 Answer