Can't have more than 1 different skybox per scene

anyone know why is this happening?
i’m trying to have a different skybox per scene but when i change a skybox on
one scene, it changes for all my scenes

This setting applies to all scenes.

You can change your skybox by script using RenderSettings: https://docs.unity3d.com/ScriptReference/RenderSettings.html

RenderSettings.skybox = yourNewSkybox;

Instead of using the global skybox setting, add a skybox component to your camera and add the skybox material to it there.

2 Likes

won’t this give the same result, since i have to change the script for a different skybox?

i already tried to add to camera and it changes for all scenes

Using if statements could be enough, depending on what you want to do. The script below works, I’ve tested it:

Script:

using UnityEngine;
using UnityEngine.SceneManagement;

public class GameManager : MonoBehaviour
{

    private static GameManager gameManager;

    public Material skybox_a;
    public Material skybox_b;

    private void Awake()
    {
        if(gameManager != null && gameManager != this)
        {
            Destroy(gameObject);
            return;
        }

        gameManager = this;

        DontDestroyOnLoad(gameObject);
    }
    private void Start()
    {
        Scene scene = SceneManager.GetActiveScene();

        if(scene.name == "Scene_a")
            RenderSettings.skybox = skybox_a;
        else if(scene.name == "Scene_b")
            RenderSettings.skybox = skybox_b;
    }
}

Only if you’re using the same camera object for all scenes.

Cameras use the skybox that is defined in the Lighting settings. :wink:

Yes but there is a separate component you can add to cameras to do per camera skyboxes. That’s what I’m talking about. You can even have multiple cameras in the same scene with different skyboxes running at the same time. You add the skybox material to this component attached to the camera instead of the main rendersettings skybox.

From my previous link:

https://docs.unity3d.com/Manual/class-Skybox.html

1 Like

Okay, my bad, I tried this and it works.

But I prefer my script. :stuck_out_tongue:

1 Like

i think it works if you add diferent cameras to different scenes i will try this thank you

1 Like