playMaker

Author Topic: event sender bug?  (Read 350 times)

aGoshAn

  • Playmaker Newbie
  • *
  • Posts: 3
event sender bug?
« on: June 19, 2022, 10:30:32 AM »
Why every time i send an event as the result of UI interaction the sender is UI but not The FSM that sends the event? What do I have to do? It's so wrong.





Solution:
Code: [Select]
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{

[ActionCategory(ActionCategory.StateMachine)]
public class SetEventSentBy : FsmStateAction
{
[UIHint(UIHint.Variable)]
[Tooltip("The GameObject that sent the event.")]
public FsmOwnerDefault sentByGameObject;

[UIHint(UIHint.Variable)]
[Tooltip("The name of the FSM that sent the event.")]
public FsmString fsmName;

public override void Reset()
{
sentByGameObject = null;
fsmName = null;
}

public override void OnEnter()
{
Fsm.EventData.SentByFsm = Fsm;
Fsm.EventData.SentByState = State;
var go = Fsm.GetOwnerDefaultTarget(sentByGameObject);

if (go != null)
{
Fsm.EventData.SentByGameObject = go;
}
else if (fsmName.Value != null)
{
Fsm.EventData.SentByFsm.Name = fsmName.Value;
}

Finish();
}
}

}
« Last Edit: June 19, 2022, 03:32:21 PM by aGoshAn »