playMaker

Author Topic: Example Actions that Listen to Events with Return Arguments? [Solved]  (Read 1772 times)

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
I am trying to create a custom action that listens for a c# delegate event and returns an event argument (event payload). Unfortunately I am having some difficulty here. This is my first time working with unity delegates and events. If there are some playmaker actions that are already do this, maybe it will help me work it out.

This is the documentation here: https://vrtoolkit.readme.io/docs/vrtk_destinationmarker

And I am trying to get the event payload "Vector3 destinationPosition".

« Last Edit: April 24, 2017, 06:56:26 AM by tcmeric »

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: Example Actions that Listen to Events with Return Arguments? [solved]
« Reply #1 on: April 24, 2017, 06:55:45 AM »
Nevermind, I think I got it to work. Example for others if they run across this:

From VRTK snap zone.

Code: [Select]
public override void OnEnter()
{
var go = Fsm.GetOwnerDefaultTarget(gameObject);

snapEvents = go.GetComponent<VRTK.UnityEventHelper.VRTK_SnapDropZone_UnityEvents>();
if (snapEvents == null)
{
snapEvents = go.AddComponent<VRTK.UnityEventHelper.VRTK_SnapDropZone_UnityEvents>();
}

snapEvents.OnObjectEnteredSnapDropZone.AddListener(ObjectSnapped);

}

private void ObjectSnapped(object sender, SnapDropZoneEventArgs e)
{
snapZoneObject.Value = e.snappedObject;

}