Playmaker Forum
PlayMaker Updates & Downloads => Share New Actions => Topic started by: giyomu on July 05, 2011, 02:27:19 AM
-
yes this is my action day XDD
something i found myself very handy when working in iOS / Android and testing in unity editor to set up various control or behavior regarding your target platform.
using UnityEngine;
using HutongGames.PlayMaker;
[ActionCategory(ActionCategory.Input)]
[Tooltip("Check which platform we are running, useful to set various type of input corresponding to platform used use one action per platform")]
public class CheckPlatform : FsmStateAction
{
public RuntimePlatform platform;
public FsmEvent platformEvent;
public override void Reset ()
{
platform = RuntimePlatform.OSXEditor;
platformEvent = null;
}
public override void OnEnter ()
{
DoCheckPlatform();
Finish();
}
void DoCheckPlatform()
{
if(Application.platform == platform)
Fsm.Event(platformEvent);
}
}
-
Brilliant thanks!
I added the PlayMaker namespace to avoid errors when putting this directly into Unity.
using UnityEngine;
using HutongGames.PlayMaker;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Input)]
[Tooltip("Check which platform we are running, useful to set various type of input corresponding to platform used use one action per platform")]
public class CheckPlatform : FsmStateAction
{
public RuntimePlatform platform;
public FsmEvent platformEvent;
public override void Reset ()
{
platform = RuntimePlatform.OSXEditor;
platformEvent = null;
}
public override void OnEnter ()
{
DoCheckPlatform();
Finish();
}
void DoCheckPlatform()
{
if(Application.platform == platform)
Fsm.Event(platformEvent);
}
}
}