I would like to set up a field in the inspector where the user can drag a Unity Scene from the Project tab.
Not having much luck.
I cannot find what this Asset field type should be and fromt he forum I am gathering that there isn’t one available. Is this still the case?.
If it is the case. I was thinking that I could extend the the editor somehow in such a way that the user could drag the Scene asset, then the editor would convert the asset to the assetpath as text and store that.
It seems like it would work except that the user cannot drag the object into the box because the box is a text field.
Can I override the drop behaviour of the inspector field so it will accept whatever type I tell it to?
Here’s a simple solution that I just found that worked for my game. I attached this “scene loader” script to an object with a collider on it. This lets you drag a scene from your project files into the inspector. You can rename the scene in your project folder, and it still works with no additional tweaking
[SerializeField] Object scene;
private void OnTriggerEnter(Collider other) {
if (other.CompareTag(“Player”)){
SceneManager.LoadScene(scene.name);
}
}