playMaker

Author Topic: Detect platform: Android or iOS  (Read 3594 times)

doppelmonster

  • Full Member
  • ***
  • Posts: 157
    • Grinder Games
Detect platform: Android or iOS
« on: June 12, 2013, 11:02:50 AM »
Hi,
im trying to detect on which platform my game is running: ios or Android

i think i need a custom action for this, so i tried a lot, but dont get it to work.

here is the code im using:

Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.

using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Device)]
[Tooltip("Set a Bool value if device is iOS or Android")]
public class IphoneBool : FsmStateAction
{
[UIHint(UIHint.Variable)]
[Tooltip("Iphone = True , Android = false")]
public FsmBool deviceIsIos;

public override void OnEnter()
{
    if (Application.platform == RuntimePlatform.Android)
{
    deviceIsIos = false;
Finish();
    }
if(Application.platform == RuntimePlatform.IPhonePlayer)
    {
deviceIsIos = true;
Finish();
}
   
}
}
}

any help greatly appreciated  :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Detect platform: Android or iOS
« Reply #1 on: June 17, 2013, 07:01:21 AM »
Hi,

you need to use .Value to set the boolean value of your variable "deviceIsIos".

 so your code should be

Code: [Select]

deviceIsIos.Value = true;



bye,

 Jean