Public Scene Variables not appearing in the inspector

I am aware that this question has been asked before but I have searched for the answer and none of the proposed solutions have worked for me. I have checked both of the scripts in my project currently for errors and have found none. My variable is public.

Script the variable is in:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class doorEnterController : MonoBehaviour {

    public Scene toLoad;

    // Use this for initialization
    void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		
	}
}

The other script in my project:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class playerController : MonoBehaviour {


	// Use this for initialization
	void Start () {

	}
	
	// Update is called once per frame
	void Update () {
		
	}

    void FixedUpdate()
    {
        if (Input.GetKey(KeyCode.W))
        {
            gameObject.transform.Translate(new Vector3(0, 0.1f, 0));
        }
        if (Input.GetKey(KeyCode.S))
        {
            gameObject.transform.Translate(new Vector3(0, -0.1f, 0));
        }
        if (Input.GetKey(KeyCode.A))
        {
            gameObject.transform.Translate(new Vector3(-0.1f, 0, 0));
        }
        if (Input.GetKey(KeyCode.D))
        {
            gameObject.transform.Translate(new Vector3(0.1f, 0, 0));
        }

    }
}

Hi @drearyplane

Unity editor doesn’t serialize that many types, and Scene is not derived from those that are serializable… (UnityEngine.Object, GameObject, ScriptableObject, primitive data types etc).

So having a public in front of field doesn’t automatically make something serializable in Unity inspector, if at all. If you are expecting similar behavior like you’d get with TextAsset (being able to drag’n’drop text file to inspector field) you are not going to get it I guess…

Someone more skilled can probably give you more technical answer, but hope this helps.

See:

Look here: https://forum.unity.com/threads/how-to-link-scenes-in-the-inspector.383140/ - a custom script for the editor to be able to reference scenes in the inspector;
and here: Unity - Scripting API: SceneAsset - official Unity documentation about referencing scenes in the Editor.
So, you can’t just make a scene variable visible in the Inspector as you do with other variables.

real late answer, but for those looking for, the best way to do it is using the type SceneAsset. this way the Scene you want can be used as public/serializable in the editor, can be attributed and used as you wish.

same lib, SceneManagement, and must add the scenes you wish to use to the buiild settings too.