Help with message execution target

Hi,

I have two scripts on the same gameobject.

One script does some stuff, and then I am trying to send that stuff to the other script also on the same gameobject.

It was my understanding that a Message would be the best solution. I have implemented an interface etc, but when I try to execute the message, I get an error saying I cant access the GameObject.

ExecuteEvents.Execute<INewMessage>(this.CurrentGameObject, null, (x, y) => x.SetNewCollection(PC));

I have a public GameObject variable declared and drag the gameobject to it in the editor. Can someone please let me know how to specify the target, if indeed I should be using the GameObject in this way.

Thanks,

Can you paste the exact error message?

HI GroZZleR,
Thanks for the response - I have it fixed now, by making the call in the Update method. This is mostly me getting my head around how the objects referenced in Unity script is attached to the engine runtime.

It’s a little ugly needing to specify it directly in the update just so we have access to the primary thread in the engine, makes for some awful code, would be better if we could have dispatched/invoked into the thread from anywhere.

But like everything in life, just need to work through the changes to understand them better.

Cheers