playMaker

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

refinedgames

  • Playmaker Newbie
  • *
  • Posts: 16
    • View Profile
Sending EventData in C#[SOLVED]
« on: October 25, 2013, 12: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 27, 2013, 10:27:52 PM by jeanfabre »

refinedgames

  • Playmaker Newbie
  • *
  • Posts: 16
    • View Profile
Re: Sending EventData in C#
« Reply #1 on: October 25, 2013, 01: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, 01:36:44 PM by refinedgames »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14109
  • Official Playmaker Support
    • View Profile
Re: Sending EventData in C#
« Reply #2 on: October 25, 2013, 11:07:27 PM »
Hi,

 What are the errors?

bye,

 Jean

refinedgames

  • Playmaker Newbie
  • *
  • Posts: 16
    • View Profile
Re: Sending EventData in C#
« Reply #3 on: October 27, 2013, 03: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?).