playMaker

Author Topic: Should the uGUI Proxy component communicate event info?  (Read 3557 times)

bfd

  • Playmaker Newbie
  • *
  • Posts: 21
Should the uGUI Proxy component communicate event info?
« on: February 14, 2016, 06:08:52 PM »
I'm trying to have an FSM check which button was pressed, but the 'get event info' action is currently not pulling the GameObject that sent the event.

Does the "sent by object" event info get lost when the event is sent through the uGUI proxy? Or am I doing something wrong that is causing it not to be received? It's a pretty simple configuration so I can't really imagine what I've done wrong (though it's certainly a possibility!) The action to get event info is the first thing that happens in the FSM too.

I'd rather avoid a separate FSM on each button to manually record when it has been clicked, I figure that's the point of letting you get the sender from the 'get event info' action - but if it doesn't work through the proxy obviously I'll need a work-around.

Thanks!

EDIT: I'm not sure if it's related, but Playmaker is giving me an error because the button is a prefab and the GameObject FSM it's sending an event to already exists in the scene. It seems like the connection is not completely broken, because the scene GameObject does receive the event from the prefab button, it just doesn't receive the event info. Though as the warning states it does lose this reference on save/load.

I can understand why prefabs shouldn't reference scene objects, but I'm not sure how else to approach this when the button needs to be instantiated on runtime. The GameObject it should reference is stored as a global variable, so I could theoretically tell the button to pull that info when it's instantiated, but I can't find any actions that let me actually modify the uGUI proxy component via an FSM.

Any tips or advice on this would be greatly appreciated!
« Last Edit: February 14, 2016, 09:34:36 PM by bfd »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Should the uGUI Proxy component communicate event info?
« Reply #1 on: February 15, 2016, 01:41:06 AM »
Hi,

 you need to use "GetLastPointerEventData" for the following uGui Proxies : drag, drop and pointer.

For the PlayMakeruguiComponentProxy, GetEventInfo works, you'll get a float, a bool or a string depending on the component you targeted.

Bye,

 Jean

bfd

  • Playmaker Newbie
  • *
  • Posts: 21
Re: Should the uGUI Proxy component communicate event info?
« Reply #2 on: February 15, 2016, 04:51:08 AM »
Hi Jean,

Thanks for the reply. I'm glad to hear that GetEventInfo is working for the uGUI component proxy, even if I can't seem to get it working myself!

In my project, the proxy is on a button that is simply clicked so I can rule out the need for GetLastPointerEventData.

I must admit I'm a bit confused when you say I'll get a float, a bool or a string as a result of GetEventInfo. What I'm looking for is none of those types - I want to find the actual GameObject that sent the event. It's part of the GetEventInfo action, so I would imagine it can be done with the uGUI component proxy, but you didn't mention it in your post so that's why I'm hoping you can clarify.

Given that GetEventInfo should behave correctly on a uGUI component proxy, but isn't in my project, the only explanation I can come up with is that it's a result of the fact that I have a prefab referencing a scene object. Is there a recommended workflow for achieving this functionality without having a prefab/scene object link?

As a different approach I just tried removing the target from the uGUI proxy and using a SetProperty action in the prefab's own FSM to pull the correct GameObject from the global variable where it is stored and update the proxy component data to reference this GameObject. Unfortunately that isn't updating the proxy component when it runs. SetProperty does seem a little funny with the proxy. I'm sure the first time I created an action I simply dragged the component into the editor and got the usual 'Set/Get Property' options. However now when I try I get 'No Drag and Drop Actions found for this asset type' and I have to manually create a Set Property and link it to the proxy component. Based on that I'm not convinced that SetProperty is cooperating with the proxy component.

I'm also not sure if I can use this action to ensure the custom event name being triggered is correct. There doesn't seem to be anything in SetProperty for the proxy that allows me to set the Event (Custom) unless the labeling in SetProperty is different from the labeling in the inspector.

Thanks,

Steve

bfd

  • Playmaker Newbie
  • *
  • Posts: 21
Re: Should the uGUI Proxy component communicate event info?
« Reply #3 on: February 15, 2016, 03:32:01 PM »


These are the options I have under 'property' in the SetProperty action. I'm assuming GameObject is the correct property to set the component proxy's target, but it doesn't seem to be working.

I tried 'name' out of curiosity and it just changes the GameObject's name in the scene. 'Action' just refers to 'Send FSM Event' or 'Send FSM Variable' so I'm not too sure what else to try.

bfd

  • Playmaker Newbie
  • *
  • Posts: 21
Re: Should the uGUI Proxy component communicate event info?
« Reply #4 on: February 15, 2016, 09:28:45 PM »
Sorry for the multiple posts, but as I'm adding several more images I thought it was worth creating a new post.

I just did a test of the same behaviour but without any prefabs and the FSM is still not receiving the event sender GameObject through the proxy. So it seems I have two separate issues:
  • Getting a prefab GUI object to target a scene object
  • Getting the sender info from a uGUI component proxy
As mentioned I have a few images documenting the test I just did. It's very simple, so I don't believe there are any problems with the process itself - but I could be wrong!

Playmaker uGUI Component Proxy



Action intended to get sender info



Sender variable before event is triggered



Sender variable after event is triggered



If I've done something incorrectly please do let me know - but it appears as though get sender is not possible through the uGUI component proxy at present.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Should the uGUI Proxy component communicate event info?
« Reply #5 on: March 30, 2016, 06:26:55 AM »
Hi,

 Indeed, the sender is unknown in this case. you have several options to get around this:

-- fire very specific events so that the event itself is telling exactly where it comes from. So for example on the "Play" button, create a dedicated event "ON PLAY BUTTON CLICK", that only this button is allowed to fire as a convention in your game.

-- fire a regular generic ON CLICK to the owner of the button, and the fsm on this will in turn send the same event, that event will feature who sent it. so you simple need to compose that way so that you can get the sender information

Bye,

 Jean