Yes, you can achieve both of your goals in Unity using additive scene loading [docs]. Additive scene loading allows you to load multiple scenes simultaneously, and you can even overlay scenes on top of each other. Something like this:
Create two scenes, Scene1 and Scene2, and set up their UI elements as required.
In Scene1, create a script (e.g., SceneController.cs) and attach it to an appropriate GameObject (e.g., a button). Add the following code to load Scene2 additively when the “Settings” button is clicked:
using UnityEngine;
using UnityEngine.SceneManagement;
public class SceneController : MonoBehaviour {
public void LoadSceneAdditively() {
SceneManager.LoadScene("Scene2", LoadSceneMode.Additive);
}
}
In Scene2, set the UI elements’ Canvas component’s Render Mode to “Screen Space - Camera” and assign the main camera of Scene1 to the Render Camera field. This ensures that the UI elements in Scene2 will be rendered in the same space as Scene1.
To make Scene2 a fraction of the size of Scene1, you can adjust the Canvas Scaler component’s Scale Factor property of the Canvas in Scene2. This will change the size of the UI elements relative to the Scene1 UI.
In Scene2, create another script (e.g., UnloadScene.cs) and attach it to the “Back” button GameObject. Add the following code to unload Scene2 when the “Back” button is clicked:
using UnityEngine;
using UnityEngine.SceneManagement;
public class UnloadScene : MonoBehaviour {
public void UnloadCurrentScene() {
SceneManager.UnloadSceneAsync("Scene2");
}
}
Make sure to add both Scene1 and Scene2 to the Build Settings (File > Build Settings > Scenes In Build).
Now, when you click the “Settings” button in Scene1, Scene2 will be loaded additively, and Scene1 will still be running in the background. When you click the “Back” button in Scene2, Scene2 will be unloaded, and you will be able to interact with Scene1 again.
Keep in mind that when using additive scene loading, you should manage the interactions between the scenes and ensure that there are no conflicts or unexpected behavior.