Access to script from another scene by the main menu

Hi everyone,

First of all I’m a beginner in C# .
I 'm working on a project composed of 2 scenes : one for the main menu and the other one for the “game”.
In my second scene : the “game” , I’m able through the Inspector to control some stuff (like day lenght in minute …) thanks to sliders.
Here’s my question : how can I have access to these sliders in my main menu, is there any way to do that ?

Thanks for your help ! :slight_smile:

Depending on which slider you used…

Assuming it’s the UGUI slider:

using UnityEngine.UI; ← Necessary

Slider mySlider = GameObject.Find(“Slider GameObject Name”).GetComponent();

then reference mySlider.

if I understood you correctly there are two ways:

  1. You add this game object to the main menu instead of the game scene and use DontDestroyOnLoad
  2. You add this game object to the main menu. Before you load the game scene you store those values somwhere (PlayerPrefs for example) and in the game scene you load those values and set them as soon as the scene is loaded.