Playmaker Forum

PlayMaker Updates & Downloads => Share New Actions => Topic started by: giyomu on July 04, 2011, 11:27:19 PM

Title: CheckPlatform
Post by: giyomu on July 04, 2011, 11:27:19 PM
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);
}
}

Title: Re: CheckPlatform
Post by: theBrandonWu on September 12, 2014, 08: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);
}
}

}