How to know parent scene of the object?

Hello.

Is there any way to know parent scene of the gameobject in the unity?

I searched in the google and community. But I couldn’t find any way.

Help me.

Thank you.

Check this out buddy.

using UnityEngine;
using UnityEngine.SceneManagement; //this is important, pay attention here

public class SceneNameLog: MonoBehaviour {


    private void Start()
    {

     string s = gameObject.scene.name;  //you can get scene index too.
     Debug.Log(s);
    }

If I’ve understood correctly you’re looking for the current scene; You can get it by using GetActiveScene, like so:

Scene scene = SceneManager.GetActiveScene();
Debug.Log(scene.name); //print the scene name

Remember to also import:

using UnityEngine.SceneManagement;

See: Unity - Scripting API: SceneManagement.SceneManager.GetActiveScene