PlayMaker Help & Tips > PlayMaker Help

Strange Global Var Behavior - Works After Second Run[SOLVED]

(1/1)

memetic arts:
Okay, this one is really hanging me up . . . hopefully it's something stupid and someone out there can set me straight.

I have a prefab with an NGUI UITexture on it.  The prefab has several manually instantiated objects in the scene (not generated at runtime).  There is also a set of buttons representing texture options.  The desired functionality is to click a button and change the texture on the instantiated objects.  Simple enough.

I've got an FSM on each button, which, on click, gets the value of its texture, stores it in a global var, and then sets the texture on the prefab with the global var value.  This seems to work, but ONLY after running the app for the second time.  On the first try after opening the project/scene, absolutely nothing happens.  As soon as I hit "stop", the textures all change to what they should have been when I clicked the button.  And from then on, as I said, everything works as expected.

I'm guessing that the issue has to do with initializing the global var, and I've tried several approaches at doing that, but none have succeeded.

I've also tried sending events to the prefab so that it would set itself, but couldn't get that to work either,no idea why.

Any assistance here would be greatly appreciated!

Thanks!

memetic arts:
Finally solved this one . . . apparently was, indeed, an initialization issue, resolved by somehow getting Send Event to work . . . I think the trick was to use "broadcast all" vs. to a specific game object FSM.

I think a little sleep helped as well . . .

And for other relative newbies like me, the underlying lesson here is that the most direct way to set props on a prefab is to include all of the Set Property actions on the prefab itself, and trigger them with a global "broadcast all" event, to which only the prefab is listens for.

cheers . . .

Navigation

[0] Message Index

Go to full version