playMaker

Author Topic: custom type in events  (Read 1987 times)

Agosh

  • Playmaker Newbie
  • *
  • Posts: 5
custom type in events
« on: November 12, 2013, 03:17:34 AM »
Greetings. Can I send variables in the event of custom type? Whether you plan to implement it

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: custom type in events
« Reply #1 on: November 12, 2013, 04:21:18 AM »
Hi,

 You can send an FsmObject, which is basically any class that implement a Unity.Object . Would that do?

 Else, are you able to script? what custom type would like to pass in the event data?

bye,

 Jean

Agosh

  • Playmaker Newbie
  • *
  • Posts: 5
Re: custom type in events
« Reply #2 on: November 13, 2013, 12:15:58 AM »
I am confused. Tell me, please, for example. If I want to send from one to the other FSM: public MyResource [] CoastValue;

///-------------
using UnityEngine;
using System.Collections;

public class MyResource: MonoBehaviour {
public GameObject   Type;
public int                Count;
}
///-------------
What do I need to do? In normal cases I used the Set Event Data and Send Event Actions. Sorry for my slowness. I should be grateful for the help.

Agosh

  • Playmaker Newbie
  • *
  • Posts: 5
Re: custom type in events
« Reply #3 on: November 14, 2013, 02:50:51 AM »
I understand your answer. Thank you :)
You mean the fact that in a variable of type Object is a field Object Type.
« Last Edit: November 14, 2013, 02:52:42 AM by Agosh »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: custom type in events
« Reply #4 on: November 14, 2013, 03:25:13 AM »
Hi,

 Sending from one fsm to the other MUST be done done within playmaker itself, using a Fsm and state with an action "Send event" targeting that other fsm. The event must be global to be listed and available and the other fsm must implement it either as a transition or better as a global transition.

 Now, if you want to send an event from a monobehavior to an fsm, the quickest approach is to broadcast using this call:

Code: [Select]
PlayMakerFSM.BroadcastEvent ("MY GLOBAL EVENT");
You need to mention that you use playmaker in your monobehavior as well:

Code: [Select]
using HutongGames.PlayMaker;
Now to fire to a specific FsmComponent, you will need to get a reference to it, but that's a standard thing, since a fsm is a regular component like anything else you drop on a gameObject, then you can use:

Code: [Select]

PlayMakerFSM fsm = this.getComponent<PlayMakerFSM>();

...
...

fsm.SendEvent("MY EVENT");



Does that help a bit?

Study the various scripts done in the Photon bridge, they use a lot of these. for example:

PlayMakerPhotonProxy.cs

 Bye,

 Jean