HasReceivedEvent call to SharedVariable<T>.SetValue(object) throws InvalidCastException

Thing2

New member
I'm having trouble getting HasReceivedEvent to save the value of an event parameter in a SharedVariable indicating the MonoBehavior that sent that event.

The correct event parameter value makes it into HasReceivedEvent.ReceivedEvent(object), which calls storedValue1.SetValue(arg1). But that storedValue1 is somehow a SharedGenericVariable, whose type string field indicates "SharedGameObject". When SharedVariable<GenericVariable>.SetValue(object) assigns mValue = (T)value, it throws InvalidCastException.

My MonoBehavior subclass is called UserHost. Here I've defined a variable named hostSpeaking of type SharedUserHost:
hostSpeaking part 1.png

And here I have a HasReceivedEvent conditional storing its event parameter in that SharedUserHost variable named hostSpeaking:
hostSpeaking part 2.png

And here is the state of things when the typecast fails:
hostSpeaking part 3.png

Why is the type I select in the Variables pane not the type that receives the value from HasReceivedEvent?
What do I need to do here instead?

Cheers,
 
Are you running the latest version? There were some changes to SetVariableValue which may fix this situation. If it doesn't can you list how to reproduce the problem from a fresh project so I have a better idea?
 
Hey, sorry for not responding earlier; I was unavoidably delayed because of a winter storm.

I'm running the version that was current as of a couple of weeks ago, at least. If there's been no update since then, I'll see about getting you a minimal repro project as soon as I get a chance in the next week or so.

Thanks for the reply, and Happy New Year to you and yours.
 
I'm pretty sure this issue is now resolved in my project, but I'm not clear on what I did that fixed it. While investigating potential workarounds, I created another shared variable of the same type, and eventually deleted the original one, so that may have corrected an issue. But my best guess is that I stopped doing something stupid workflow-wise with a BT in a prefab.
 
Top