playMaker

Author Topic: CheckPlatform  (Read 4268 times)

giyomu

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 108
    • blog
CheckPlatform
« 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.

Code: [Select]
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);
}
}


theBrandonWu

  • Playmaker Newbie
  • *
  • Posts: 18
    • Studio Pepwuper
Re: CheckPlatform
« Reply #1 on: September 12, 2014, 11:16:44 AM »
Brilliant thanks!

I added the PlayMaker namespace to avoid errors when putting this directly into Unity.

Code: [Select]
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);
}
}

}

Studio Pepwuper: http://www.pepwuper.com
One Month Game School (now on SkillShare): https://www.skillshare.com/r/user/thebrandonwu