Forum rules - please read before posting.
Tech questions during the weekend? Drop in on the community Discord channel!

Question: Saving actionList parameters values

Hi

First of all, Thank you, Chris, for this amazing product, a very well designed, performed, customizable, documented and maintained product, I really enjoy working with it.

My question:
(using Unity: 2019.2 , AC: 1.69.5)

When saving a game, How can I save an actionList (asset/scene) current parameters values?

Lets take as an example the "generic enter closeUp"/ "generic exit closeUp" actionList assets that were introduced in the 3D game tutorial: the "enter closeUp" actionList sets values to parameters in the "exit closeUp" actionList.
If I save a game while in closeUp, the values that were set (to the "exit closeUp" parameters) are not saved. Then ,when I load the saved game the "exit closeUp" doesn't work correctly.

The example above is for an actionList asset that uses parameters, but the same happens with scene actionList with parameters.

Is there a way to save the these values (without storing them in global variables)?

thanks,
shayk

Comments

  • Welcome to the community, @shayk.

    Do note that - if in this or some other situation - you can temporarily prevent saving with the Engine: Manage systems Action. Locking saving during a close-up would be a "quick hack" way of resolving the issue.

    As for the question: parameter data is currently saved if the ActionList has been paused using the ActionList: Pause or resume Action. If, after loading a save game, the ActionList is then resumed (scene- or asset-based), it should restore the parameters.

    However, it should also be possible to write a custom Remember script to save/load the parameters for a scene-based ActionList. Something like this ought to do it:

    using System.Collections;
    using UnityEngine;
    using AC;
    
    public class RememberActionListParameters : Remember
    {
    
        public override string SaveData ()
        {
            ActionListParamData data = new ActionListParamData();
            data.objectID = constantID;
            data.savePrevented = savePrevented;
    
            data.paramData = GetComponent <ActionList>().GetParameterData ();
    
            return Serializer.SaveScriptData <ActionListParamData> (data);
        }
    
        public override void LoadData (string stringData)
        {
            ActionListParamData data = Serializer.LoadScriptData <ActionListParamData> (stringData);
            if (data == null) return;
            SavePrevented = data.savePrevented; if (savePrevented) return;
    
            GetComponent <ActionList>().SetParameterData (data.paramData);
        }
    
    }
    
    [System.Serializable]
    public class ActionListParamData : RememberData
    {
    
        public string paramData;
    
        public ActionListParamData () { }
    
    }
    

    Just one thing: in ActionList.cs, make the "SetParameterData" function public.

    Saving ActionList Assets isn't so simple, because you're dealing with runtime instances of the asset - not the asset itself. One thing you could try is to create a Cutscene, set the Actions Source to Asset File, and have it reference the "Close up" asset.

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.
Do NOT follow this link or you will be banned from the site!