Unity Scene Management suggestions required

hello there unity devs and fellow people i have some questions about how i can possiblity improve on this piece of code.

scene = SceneManager.GetActiveScene();

        if (scene.name == "FirstGame")
        {
            Screen.orientation = ScreenOrientation.Landscape;
            Debug.Log("Scene : " + scene.name + " ");
            return;
        }

        else if (scene.name == "GameSelectorScreen")
        {
            Screen.orientation = ScreenOrientation.Landscape;
            Debug.Log("Scene : " + scene.name + " ");
            return;
        }

        else if (scene.name == "StartMenu")
        {
            Screen.orientation = ScreenOrientation.Portrait;
            Debug.Log("Scene : " + scene.name + " ");
            return;
        }

code above runs everytime frame but how can i avoid that?.
is there some way of waiting til a scene has been loaded and then do this?

You should be able to add a callback for when the scene is loaded:

using UnityEngine.SceneManagement;

void OnEnable() 
{
      SceneManager.sceneLoaded += OnSceneLoaded;
}

void OnDisable() 
{
      SceneManager.sceneLoaded -= OnSceneLoaded;
}

private void OnSceneLoaded(Scene scene, LoadSceneMode mode) 
{
   //do stuff
}

Source: Since OnLevelWasLoaded is deprecated (in 5.4.0b15) What should be use instead? - Questions & Answers - Unity Discussions

btw i solved it did a few extra check

if (FirstLoad == true)
        {
            scene = SceneManager.GetActiveScene();

             if (scene.name == "StartMenu")
             {
                    Screen.orientation = ScreenOrientation.Portrait;
                    Debug.Log("Scene : " + scene.name + " ");
                    FirstLoad = false;
             }
        }
       

      
        else if (SceneLoading == true)
        {
           
            if (scene.name == "FirstGame")
            {
                Screen.orientation = ScreenOrientation.Landscape;
                Debug.Log("Scene : " + scene.name + " ");
                SceneLoading = false;

            }

            else if (scene.name == "GameSelectorScreen")
            {

                Screen.orientation = ScreenOrientation.Landscape;
                Debug.Log("Scene : " + scene.name + " ");
                SceneLoading = false;

            }


            else
            {
                scene = SceneManager.GetActiveScene();
            }
        }

Definitely do what tonemcbride says. Then you dont have to do anything every frame. The function gets called when the scene changes only so you can check the scene name there.