call function before scene gets unloaded unity code example Example: unity calling method before unloading scene SceneManager.sceneUnloaded += MyFunction;