cashing in Scenes to a public vaiable

Is there a line of C# code that would let me drag and drop scenes into the inspector?

Okay i have right now have “Application.LoadLevel(“MainScreen”)”

I want to to make the word “MainScreen” a variable so people can just drag and drop the scene (that they want to be the main Screen)

basically so that they can change the sene without editing the code =D.

While dreamblur tells you how to load a scene based on it’s name, he doesn’t tell you how to actually ‘drag and drop’ this scene into the inspector and have the inspector sort out the name. I can imagine there are cases where you’re setting up a menu when you don’t want to type twenty levelnames, but would much rather drag and drop them in.

To do that you need to write a custom inspector. This below assumes you have one script named LoadLevel, which will load a level based on what you drag and dropped, and a second script (in a folder named Editor!) called LoadLevel_Editor. What you will get is the same you get when, in a normal script, you type var someTransform:Transform, with a field where you can drag and drop the Transform in, but here it’s a scene you drop in.

//script name is LoadLevel_Editor
@CustomEditor( LoadLevel ) class LoadLevel_Editor extends Editor
	var type : String = "(DefaultAsset)"; //GetDragAndDropTitle returns a name + type, in this case LevelName(DefaultAsset), we want to remove the DefaultAsset part
	var fullName : String;
	override function OnInspectorGUI()
		GUILayout.Label( fullName );
		target.scene = EditorGUILayout.ObjectField( target.scene, Object );
		if( target.scene != null )
			fullName = levelName = ObjectNames.GetDragAndDropTitle( target.scene );
			var charArray = type.ToCharArray();
			target.levelName = levelName.TrimEnd( charArray );

//script name is LoadLevel
var levelName : String;
var scene : Object;
function LoadLevel()
	Application.LoadLevel( levelName );