Forum rules - please read before posting.

Having a global Action to be called "OnLoad" on each scene - without doing per-scene editing.

edited December 2019 in Technical Q&A

Hi there!

I have quite a lot of scenes in my current game, and I need to execute some code right after each time a scene is loaded from a savegame.

Basically, I'd need the OnStart field of the scenes to be using scene Actionlists, and the OnLoad to be using ActionListAssets - but without manually filling it, I'd need some code to be executed regardless of the scene content.

Only 1 condition: I need to change the game systems and player properties after the savegame gets loaded, basically overriding the player/systems saved states.

The actionlist asset I could be calling could be as simple as:

but I may be doing a few extra checks, which needs not to be overwritten when a game gets loaded.

I could create, manually, a local script which runs an asset actionlist, but that's the worst case scenario.

Is there any way to hook into scene loading, from a component that gets automatically instantiated in all scenes by AC?

Would a prefab dropped in all scenes be able to register to the OnLoad event, before it gets triggered by a savegame load event?

Even "temporary" hacks to AC's code are welcome.

Comments

  • See the Manual's "Save scripting" chapter for a list of the available events:

    OnBeforeSaving (int saveID);
    OnFinishSaving (SaveFile saveFile);
    OnFailSaving (int saveID);
    OnBeforeLoading (SaveFile saveFile);
    OnFinishLoading ();
    OnFailLoading (int saveID);
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.