Not a Bug

data added using Add List Item to a List Literal is retained on exiting play mode

Vong 2 years ago updated by Personuo 2 years ago 7 1 duplicate

Seems to be an bug / unintended consequence of List Literal, Add List Item, and retaining edits in Play Mode.

Anecdotally feel like this wasn't the case a week or two ago, but don't quote me on that.

1) Have an empty [List of ... Literal]
2) Add a bunch of stuff to it using [Add List Item]
3) Enter and exit Play Mode a bunch of times
4) The List Literal is now full of duplicated items

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):

Duplicates 1


That's... an interesting bug that seems to be "by-design". Because the list literal is saved inside the macro asset, changes to it persist play mode exit, like all ScriptableObjects in Unity!

In Bolt 2, we'll (almost surely) be retiring List of X Literal units and replace them by Create List of X units instead, thanks to our new full generic support. It's a small change, but it means a new list will be created instead of using a pre-existing list.

In the mean time, you can always use the (non-generic) Create List unit to avoid this issue. Of course, the drawback with that approach is that you'll have to use literal nodes instead of inline string inspectors.

Yea, it seemed like a confluence of design decisions rather than a straight up bug.

I thought non-generic Lists were discouraged for JIT platforms? atleast according to the Simplify Lists post you made.. 8 months ago.

As a workaround, is there any drawbacks to creating List<T> along with accompanying methods (indexOf, FindLast) in a c# script and using the reflected units from that? I've been under the impression that there must be a reason why its not included in Bolt.. but I've also been terminally confused with Lists for a while now.

Right now they are discouraged for AOT platforms, yes. But on JIT, they should be fine.

In Bolt 2, with script generation and full generic support, they will become the standard for lists and will work seamlessly everywhere.

A wrapper script will work well, but there's no reason to avoid Create List if it works for you!

I want like this code "Variables.Object(parentPg.gameObject).Set("enemyList", new List<GameObjcet>());"

Pending Review

Hi Persuonuo,

This is a design issue with the way we handle lists in Bolt 1. I'm merging this thread with another that already reported it.

The suggested workaround is to use the Create List unit instead of a List Literal unit.

yes, Create List is valid,thank you