Playmaker Forum

Playmaker Help & Tips => Playmaker Help => Topic started by: refinedgames on October 25, 2013, 12:25:33 PM

Title: Sending EventData in C#[SOLVED]
Post by: refinedgames 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 (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.  :)
Title: Re: Sending EventData in C#
Post by: refinedgames 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?
Title: Re: Sending EventData in C#
Post by: jeanfabre on October 25, 2013, 11:07:27 PM
Hi,

 What are the errors?

bye,

 Jean
Title: Re: Sending EventData in C#
Post by: refinedgames 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?).