Is there a way to make a script do something every time a new level loads?

I have a bit of a problem, I’ve just recently added graphics options to my game, and it works fine, that is until I load a new level, then everything, with the exception of texture quality, resets.

I’ve made it so that the object that stores the graphic options data, doesn’t get destroyed when a new level loads (DontDestroyOnLoad), but that doesn’t seem to do much, I need to somehow make it so that when a new level is loaded, it sets all of the graphic options to the users preference, is there anyway I can do that?

I think I remember hearing about a void that does that, but I can’t for the life of me remember what it was called, and I can’t find the video where I heard about it.

Also, I’m wondering if it’s possible to detect the aspect ratio of the players resolution, because I have loading screens set up for the game, and want to have widescreen load screens for widescreen resolutions and a normal ratio for the others.

Monobehaviour.OnLevelWasLoaded (int level) will fire when a certain level is loaded. If I were you, I would have the graphics object get destroyed when changing scenes, then just have one graphics object in every scene that you need it. Then whatever code you put in Awake () or Start () will get executed at the start of each scene. And Camera.aspect will return a float that is the aspect ratio (width/height)