Forum rules - please read before posting.

Create Scene and Dynamically load into game at runtime?

Hi, I'm a newbie with AC and would like to know how to do the following:

I have a project that currently has 3 scenes, now I would like to create additional AC scene in unity editor and then dynamically load that new scene into the game at runtime. This way I don't have to submit a new update of the app each time a new scene is created. Can you suggest a way to do this.

Cheers.

Comments

  • Welcome to the community, @256bits.

    Can you elaborate what you mean by "dynamically load"? What is the exact situation you're looking to achieve?

    Scenes normally have to be added to Unity's Build Settings for them to be accessable in builds. They can, however, also be accessed if either in an Asset Bundle, or an Addressable bundle.

    For Asset Bundles, you would have to manage the downloading/loading of the correct bundle - but once correctly present you should then be able to open scenes it contains as normal.

    For Addressables - i.e. using Unity's Addressable system, and the way I recommend - you can assign a Key to a scene asset file and then reference that Key's name in AC. To allow for this, you'll need to go to the Settings Manager and set Reference scenes by to Name, and then check both Load scenes asynchronously? and Load scenes by Addressable?.

  • Thank you Chris for your answer. After diving into the documentation deeper I can now ask the correct question.

    Question: I understand that action lists can be saved as asset files. Can these asset files that are created in unity be saved and loaded into a running game at runtime?

    Use case: After publishing a game and I want to update the action list that is the logic of the game without having to make a new build of the game and uploading the new build. So I was thinking of being able to just update the Action List Logic instead of making a new build. A kind of Runtime game mod.

  • Possibly - though this touches on how Unity itself works.

    It is possible to store certain assets in Asset Bundles, and then have those Asset Bundles updated post-release without having the base executable be updated.

    You won't be able to change references to those assets, however - so preparation for the initial release would have to involve any ActionList asset you might want to update later into an Asset Bundle.

    It will also be down to a custom script to handle the loading/unloading of such a bundle - but Unity's documentation covers this here.

  • We cannot use asset bundles because they are very restrictive.

    The ideal situation is to serialize the action list assets into a json format or some way to serialize the action list into a form that doesn't require asset bundles.

    Question: How is the action list asset created and is it possible to use 3rd party EasySave2 to serialize the action list?

  • edited November 2022

    Found this code in ActionListAssets.cs
    Seems like the actionlist asset is a scriptable object.

    public static ActionListAsset CreateAsset (string assetName)
            {
                if (string.IsNullOrEmpty (assetName))
                {
                    return CreateAsset ();
                }
    
                ScriptableObject t = CustomAssetUtility.CreateAsset <ActionListAsset> (assetName);
                EditorGUIUtility.PingObject (t);
                ACDebug.Log ("Created ActionList: " + assetName, t);
                return (ActionListAsset) t;
            }
    
  • It is possible to serialize Action data as Json - scene-based ActionLists rely on Json to back up data as part of the autosaving process in the Editor.

    It should be possible to do the same for assets (or at least the Actions they hold), but you'd still need a place to store the data and means to update it. If not asset bundles or a full update, what are you considering?

  • "It is possible to serialize Action data as Json - scene-based ActionLists rely on Json to back up data as part of the autosaving process in the Editor."
    That's great to know.

    "It should be possible to do the same for assets (or at least the Actions they hold), but you'd still need a place to store the data and means to update it. If not asset bundles or a full update, what are you considering?"

    All of the data is stored on the server as media files, sound, graphics, models, etc.

    Easysave is able to serialize most of what we need into it's own format that can be updated at runtime.

  • All of the data is stored on the server as media files, sound, graphics, models, etc.

    So you'd be looking to download Action data at runtime?

    I shall look to see if the ability to convert ActionList asset data to/from Json can be added.

  • edited November 2022

    "So you'd be looking to download Action data at runtime?"
    Yes would be so awesome to be able to do this.

    "I shall look to see if the ability to convert ActionList asset data to/from Json can be added."

    That would be so Super Magical

  • edited November 2022

    I've been looking into the feasibility of Json-serializing ActionList assets for you.

    The main issue is that references to objects, such as prefabs and other ActionLists, are lost. Unity changes its internal identifiers between sessions, so data loss occurs when attempting to restore such data.

    EasySave seems to claim it can get around this, though I haven't used it myself. From their Quick Start guide, it looks like it'd be a case of something like:

    // Save
    ES3.Save("myAssetActions", myActionListAsset.actions);
    
    // Load
    myActionListAsset.actions = ES3.Load("myAssetActions", new List<AC.Action> ());
    

    While I'd still recommend the use of Asset Bundles - which, so far as I understand, are intended for this kind of situation - another option would be to use AC's ActionList scripting feature to generate ActionLists at runtime.

    See the Manual's "Generating ActionLists through script" chapter. Though scripts are normally hard-coded, I have a feeling it should be possible to rely on reflection to pull a list of Action data, from e.g. a spreadsheet, and generate them from scratch. It would be a little tricky, but I could suggest some sample code if that was worth exploring to you.

  • We can try easy save first and see how it works

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.