playMaker

Author Topic: Issues with sending data between C# script and Playmaker  (Read 2513 times)

Zanderfax

  • Playmaker Newbie
  • *
  • Posts: 14
Issues with sending data between C# script and Playmaker
« on: May 16, 2017, 06:06:47 PM »
I am using Playmaker 1.8 and I want to be able to send data along with an event.

In the scenario I have, the network is sending me a response that has a list of rooms that are open for clients to join.  I am using a prefab button that uses this data to give the player a way to join the room.

This list of rooms is updated periodically with games to remove or add.

Each room entry has a set of properties that I want to store in Playmaker so it can do the prefab instantiation. I have looked at all the documentation and I see 3 ways of doing this:

1) Set a group of variables defined in PM and then send an event that loops thru them. This works but it does not allow for me to do comparisons between games that I had seen before and what is current.

2) Set FMSEvent data and send an event. I have tried this with no success. Also based on what I am seeing, you can't send multiple pieces of data.

      Am I wrong? 
      Is there a good example of how to do this somewhere?
     
      I did download the Custom Sample EventData scene but that did not have any C# code in it to evaluate.

3) Create an object on the script side and then map it to an FSMObject variable. I have also not been able to get this to work either. Is there example code somewhere that I could look at that will show me how to do this?

Sorry for the basic questions, but data handling seems to be one of the least documented areas of the whole Unity ecosystem.. or I am missing something.

Thanks in advance for any help you can provide,

Z

PlaymakerNOOB

  • Full Member
  • ***
  • Posts: 219
Re: Issues with sending data between C# script and Playmaker
« Reply #1 on: May 16, 2017, 06:44:43 PM »
Here are some suggestions

#2, appears that you want to set a variable and then trigger an event on that gameobject? if so, apply these two actions.

Gameobject1, apply the Set FSM INT (for example)
gameobject = specify gameobject
**change from none to your gameobject
FSM name = FSM
Variable Name = Variable Name
Set Value = 10

Send Event by Name
Event Target = Game Object FSM
GameObject = Specify Game Object
**change from none to your gameobject
FSM Name = FSM
Send Event = Enter the name of the event you wish to send.  Remember that this must be an available transition for the current state, otherwise it will not work.

or #3, This video shows how to connect scripts to playmaker and send data back and forth.
 

Zanderfax

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Issues with sending data between C# script and Playmaker
« Reply #2 on: May 17, 2017, 08:38:37 AM »
Thanks for the info!

I have seen this video before.. but it only covers sending an event back to Playmaker without data. I need to send data with the event.  I got the sending events part down.. using it all over the place. :)

Z

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Issues with sending data between C# script and Playmaker
« Reply #3 on: May 19, 2017, 02:32:42 AM »
Hi,

 basically, to send data with a PlayMaker event, you use

Code: [Select]
Fsm.EventData.GameObjectData = yourGameObject;
Fsm.EventData.IntData = 123;

and then you fire your PlayMaker Event. you then use GetEventInfo to retrieve these event data.

 Bye,

 Jean

Zanderfax

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Issues with sending data between C# script and Playmaker
« Reply #4 on: May 19, 2017, 03:43:42 PM »
Jean,

What if I am sending more that one of the same type of data, for example I have 3 ints and 2 strings?

Looking at the GetEventInfo Action, It looks like I have only room for one of each. Is this true?

Z

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Issues with sending data between C# script and Playmaker
« Reply #5 on: May 23, 2017, 02:13:06 AM »
Hi,

 yep, indeed you are correct.

 for this, you should then use a special set of actions you can find on the Ecosystem. SetEventProperties and GetEventProperties.

search for "PlayMaker utils" and download that package, you will then have these two actions which will let you define many properties as event Data of various types or same types.

Bye,

 Jean

Zanderfax

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Issues with sending data between C# script and Playmaker [Solved]
« Reply #6 on: May 24, 2017, 12:04:28 PM »
Thanks!