#Passing constants/variables in bevy system
19 messages · Page 1 of 1 (latest)
Where are you getting the mpsc::channel()?
you could capture it in a closure when you register the system, otherwise if its a static function like fn my_system() { } then you'd need to make it a resource or something else so it could find it
I import it with a use statement and then I’m calling it at the top of main.
So if I stuck it in a struct I could pass it in?
no problem, yeah, you might want to wrap it with a MyChannel to avoid conflicting with types in the future
I’m going to try that. I’m getting trait bound errors left and right when I try to pass in tx as a Local
in the standard library, I believe mpsc tx is not sync, but is copyable
*clonable
So you would need to use a non send resource -
Or you could wrap it in an Arc, and then use that as a resource
Actually - there is another option... You could wrap it in a type that implements either FromWorld or Default, since Local only requires Send... But for that you need a way to grab the channel tx from the world the first time the system is called.
Is this what you meant by initializing the tx with a closure?