Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: tcmeric on April 21, 2017, 01:20:41 PM
-
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".
-
Nevermind, I think I got it to work. Example for others if they run across this:
From VRTK snap zone.
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;
}