How can i use for loop to addlistener onButtonClick?

賴志承Zisa.Lai 2 years ago updated by Lazlo Bonin (Lead Developer) 2 years ago 1

Hi, i want to use for loop to addlistener onButtonClick, but my unity console, it have error log

InvalidOperationException: The value of 'currentItem' on 'ForEach#95e69...' cannot be fetched dynamically, it must be assigned.

How can i do someting? Closure?


My version is unity 2018.1.5f1 and bolt 1.4

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

Thank you:)

Satisfaction mark by 賴志承Zisa.Lai 2 years ago

Hi Zisa,

What you are trying to do is unfortunately not supported: even listeners always fetch their target (the input port) in On Enable, before anything else in the graph is executed. This means your for each loop hasn't executed at this point.

Moreover, event listeners in Bolt cannot have multiple targets. This might become possible in the future with delegates, but at the moment each listener can only have a single target.