playMaker

Author Topic: Sending EventData in C#[SOLVED]  (Read 3446 times)

refinedgames

  • Playmaker Newbie
  • *
  • Posts: 19
Sending EventData in C#[SOLVED]
« on: October 25, 2013, 03:25:33 PM »
Hi Guys,
I'm porting from UnityScript to C#.  The following works in US:
Code: [Select]
aiStrategyFSM.Fsm.EventData.IntData = shotTypeIndex; //aiStrategyFSM is my FSM component reference, shotTypeIndex is my int var
aiStrategyFSM.SendEvent(checkStrategy);

The same code in C# throws error: "Static Member 'HutongGames.PlayMaker.Fsm.EventData' cannot be accessed with an instance reference, qualify it with a type name instead.

So according to this thread
http://hutonggames.com/playmakerforum/index.php?topic=84.msg484#msg484

I tried the following in C#:
Code: [Select]
Fsm.EventData.IntData = shotType;
aiStrategyFSM.SendEvent(checkStrategy); //send event code
But the Fsm.EventData... line throws an error: "Fsm" does not exist in the current context.  What am I missing?  My C# skills are not great... yet.  :)
« Last Edit: October 28, 2013, 01:27:52 AM by jeanfabre »

refinedgames

  • Playmaker Newbie
  • *
  • Posts: 19
Re: Sending EventData in C#
« Reply #1 on: October 25, 2013, 04:24:08 PM »
OK, surrounding my code with 'namespace HutongGames.PlayMaker.Actions' makes it compile but now other scripts don't recognize my script (so more compile errors).  This could be trouble.  Any easier way?
« Last Edit: October 25, 2013, 04:36:44 PM by refinedgames »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Sending EventData in C#
« Reply #2 on: October 26, 2013, 02:07:27 AM »
Hi,

 What are the errors?

bye,

 Jean

refinedgames

  • Playmaker Newbie
  • *
  • Posts: 19
Re: Sending EventData in C#
« Reply #3 on: October 27, 2013, 06:08:14 PM »
Thankfully I solved this.  If anyone else tries to use Fsm.EventData... in any C# script you must include:
Code: [Select]
using HutongGames.PlayMaker; //the namespace Fsm.EventData belongs toat the top of your script.  Otherwise Fsm.EventData is not recognized. 

If you are making a custom action using Fsm.EventData (such as SetEventData.cs), then wrap your script in
Code: [Select]
namespace HutongGames.PlayMaker.Actions
{
}
This is now [SOLVED] if someone wants to update the Subject Title (or can I do that?).