How do i create a scene variable?

I cant seem to find the right answer for this. I want a variable which contains scenes and you can access from the editor. I want to be able to drag a scene from assets into it.

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

public class SceneChanger : MonoBehaviour {

    public Scene level;

    void OnTriggerEnter2D(Collider2D coll) {

        if(coll.gameObject.name == "Player") {

            //Here it would use the "level" variable to load the next scene
        }
    }
}

I’m not sure that you can store an entire scene, but you can store the name of the scene as a string and launch it using the SceneManager.LoadScene method

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.SceneManagement;
 
 public class SceneChanger : MonoBehaviour {
 
     public string levelName;
 
     void OnTriggerEnter2D(Collider2D coll) {
 
         if(coll.gameObject.name == "Player") {

             // Loading the scene from it's name
             SceneManager.LoadScene(levelName);
         }
     }
 }

Try this code:

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

public class SceneChanger : MonoBehaviour {

	void OnTriggerEnter2D(Collider2D coll) {

		if(coll.gameObject.name == "Player") {

			SceneManager.LoadScene (sceneName:"level");
		}
	}
}

Instead of using a scene variable, you can use the scene’s name to switch between scenes.

Just pass the Scene name and call it. Remember to add the scene in the build settings.

 using System.Collections;
     using System.Collections.Generic;
     using UnityEngine;
     using UnityEngine.SceneManagement;
     
     public class SceneChanger : MonoBehaviour {
     
         public String level;
     
         void OnTriggerEnter2D(Collider2D coll) {
     
             if(coll.gameObject.name == "Player") {
     
                 //Here it would use the "level" variable to load the next scene
                 SceneManager.LoadScene (level);
             }
         }
     }