SerializeField Scenes

Hi, I would like to know how to make the SerializeField in the Ispector for Scenes.
It´s easy way to make it or it is harder? My code is know functional, but I must write the name of scene… I would like to drag and drop the scene…
LoadLevel couldn´t be a string, but object…but that´s not all…(I try ToString() )
And I didn´t find some command to take a name of the object. Exists?
My english is not so good…
Thanks

public class LoseCollider : MonoBehaviour {
[SerializeField] string LoadLevel;

    private void OnTriggerEnter2D(Collider2D collision)
    {
        Debug.Log("scene: " + LoadLevel);
        SceneManager.LoadScene(LoadLevel);
    }

}

I got it! :smile:
It´s different object and Object!

public class LoseCollider : MonoBehaviour {
[SerializeField] Object DragLevel;

    private void OnTriggerEnter2D(Collider2D collision)
    {
        SceneManager.LoadScene(DragLevel.name);
     }

}

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms