Forum rules - please read before posting.

SetParameter in Asset ActionList called from Toggle seems to not work

edited August 2022 in Technical Q&A

I have a Menu that displays a UI prefab for perf stats.
An ActionList asset that has a bool parameter in it named "StatsVisible" is checked and (meant to be) switched to the opposite value, and then set the lock state on that Menu.
This ActionList is referenced by the OnClick of a Toggle button, that is in my PauseMenu>Options sub-menu.

However, every time I click, it seems to take the same code path in the ActionList, implying that the "StatsVisible" parameter is not being updated or retained.

I have a Comment action at the end to confirm how many times it's being called and which path ended up happening, and it always ends in the "Toggled Stats On", and is absolutely only being called once each time I click.

Not sure what's going on here. Thanks.

AC V1.75.2
Windows 10
Unity 2021.3.2f

Comments

  • Each time an ActionList asset is run, AC actually runs instance of it inside the scene.

    Normally this isn't something that needs to be accounted for, but in the case of the ActionList: Set parameter Action's Change own? option, it's actually affecting that particular instance of the ActionList in the scene - not the original asset file.

    You should be able to get around this by unchecking this option and assigning the ActionList asset file directly - just make sure that its Revert to default parameter values after running? property is unchecked so as not to reset things when it runs, otherwise you'd have to make the same change for the Check own? boxes.

    Alternatively, you could create a Global Bool variable named StatsVisible and refer to that instead.

  • Ah okay, I thought maybe it could be something like that but wasn't sure. That alternate solution works, thanks!

    This sounds like it could be a nice option for these ActionLists to have when the Use Parameters checkbox is enabled, have another checkbox for "Persistent Single Shared Instance", and when AC code would normally instantiate an ActionList, it would first check if the option is enabled and return the direct reference instead.

    And yeah, I didn't want it to be a saved option and I didn't see an option in variables to "exclude from save". Otherwise I'd have to set up some sort of listener for save file loads and execute a check just to handle that.

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.