Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Hey Lacroiix, I noticed you wanted to be able to use the startup scene setting in the options menu but my script didn't support it. I went ahead and rewrote my script so that it automatically does the work for you :D

let activeScene: string;
let loadSceneLegacy = Sup.loadScene;

function loadScene(sceneAsset: Sup.Scene)
function loadScene(sceneAssetPath: string)
function loadScene(scene: any){
    loadSceneLegacy(scene);
    if(typeof scene == "string") {
        activeScene = scene;
        Sup.log(scene);
    }else{
        activeScene = scene.path;
        Sup.log(scene.path);
    }
}

Sup.loadScene = loadScene;

Just ignore the "loadScene" function since you don't have to use it anymore. Everything is now handled by the builtin function Sup.loadScene. I left the Sup.log calls in the function so that you'd be able to see it working in the console, so you can remove those lines after you've got it working. Once you start the game, it'll instantly set the activeScene to the scene loaded.

If you want to always use the scene's name, just replace "activeScene = scene.path" with "activeScene = scene.name", which looks like what you want in this case :)

Hope this helps!

(+2)

Hey! But this is cheating!

Just kidding :p Nice work. I would refrain from changing the API though because it could make difficult to help each other out.

An other idea would be to initialize activeScene variable to the value of the first scene instead of null. In this case, you won't have any problem with the first Sup.loadScene from the settings.

(+1)

But cheating is fun! :^)

Yeah, I agree about changing the API. It can make things messy if done too much, and causes confusion if you forget that a project handles it differently then other ones. I tried to keep it as close to the original functionality as possible without changing it's intended functionality to avoid most confusion, I just wanted to see if I could make it simple to use :)