Playmaker Forum
PlayMaker Updates & Downloads => Share New Actions => Topic started by: jeanfabre on January 21, 2014, 11:59:06 PM
-
Hi,
After a request, please find a new action that will let you fire events based on Unity platform dependent compilation flags.
http://docs.unity3d.com/Documentation/Manual/PlatformDependentCompilation.html
Warning, read properly all the different flags from the documentation above to understand when they are validated. If you run on previous versions of Unity, some Flags will never be validated because not defined ( like if running on 3.5 and checking for blackberry, this will never be available).
Bye,
Jean
-
Hi,
please find the source code, until I can send attachment again..
// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.
using System;
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Application)]
[Tooltip("Sends Events based on platform dependent flags")]
public class PlatformDependentEvents : FsmStateAction
{
public enum platformDependentFlags
{
UNITY_EDITOR,
UNITY_EDITOR_WIN,
UNITY_EDITOR_OSX,
UNITY_STANDALONE_OSX,
UNITY_DASHBOARD_WIDGET,
UNITY_STANDALONE_WIN,
UNITY_STANDALONE_LINUX,
UNITY_STANDALONE,
UNITY_WEBPLAYER,
UNITY_WII,
UNITY_IPHONE,
UNITY_ANDROID,
UNITY_PS3,
UNITY_XBOX360,
UNITY_NACL,
UNITY_FLASH,
UNITY_BLACKBERRY,
UNITY_WP8,
UNITY_METRO,
UNITY_WINRT
}
[ActionSection("Platforms")]
[CompoundArray("Count", "Key", "Value")]
[RequiredField]
[Tooltip("The platform")]
public platformDependentFlags[] platforms;
[Tooltip("The event to send for that platform")]
public FsmEvent[] events;
public override void Reset()
{
platforms = new platformDependentFlags[1];
platforms[0] = platformDependentFlags.UNITY_WEBPLAYER;
events = new FsmEvent[1];
events[0] = null;
}
public override void OnEnter()
{
int i = 0;
foreach(platformDependentFlags _flag in platforms)
{
FsmEvent _event = events[i];
#if UNITY_EDITOR
if(_flag == platformDependentFlags.UNITY_EDITOR ) Fsm.Event(_event);
#endif
#if UNITY_EDITOR_WIN
if(_flag == platformDependentFlags.UNITY_EDITOR_WIN ) Fsm.Event(_event);
#endif
#if UNITY_EDITOR_OSX
if(_flag == platformDependentFlags.UNITY_EDITOR_OSX ) Fsm.Event(_event);
#endif
#if UNITY_STANDALONE_OSX
if(_flag == platformDependentFlags.UNITY_STANDALONE_OSX ) Fsm.Event(_event);
#endif
#if UNITY_DASHBOARD_WIDGET
if(_flag == platformDependentFlags.UNITY_DASHBOARD_WIDGET ) Fsm.Event(_event);
#endif
#if UNITY_STANDALONE_WIN
if(_flag == platformDependentFlags.UNITY_STANDALONE_WIN ) Fsm.Event(_event);
#endif
#if UNITY_STANDALONE_LINUX
if(_flag == platformDependentFlags.UNITY_STANDALONE_LINUX ) Fsm.Event(_event);
#endif
#if UNITY_STANDALONE
if(_flag == platformDependentFlags.UNITY_STANDALONE ) Fsm.Event(_event);
#endif
#if UNITY_WEBPLAYER
if(_flag == platformDependentFlags.UNITY_WEBPLAYER ) Fsm.Event(_event);
#endif
#if UNITY_WII
if(_flag == platformDependentFlags.UNITY_WII ) Fsm.Event(_event);
#endif
#if UNITY_IPHONE
if(_flag == platformDependentFlags.UNITY_IPHONE ) Fsm.Event(_event);
#endif
#if UNITY_ANDROID
if(_flag == platformDependentFlags.UNITY_ANDROID ) Fsm.Event(_event);
#endif
#if UNITY_PS3
if(_flag == platformDependentFlags.UNITY_PS3 ) Fsm.Event(_event);
#endif
#if UNITY_XBOX360
if(_flag == platformDependentFlags.UNITY_XBOX360 ) Fsm.Event(_event);
#endif
#if UNITY_NACL
if(_flag == platformDependentFlags.UNITY_NACL ) Fsm.Event(_event);
#endif
#if UNITY_FLASH
if(_flag == platformDependentFlags.UNITY_FLASH ) Fsm.Event(_event);
#endif
#if UNITY_BLACKBERRY
if(_flag == platformDependentFlags.UNITY_BLACKBERRY ) Fsm.Event(_event);
#endif
#if UNITY_WP8
if(_flag == platformDependentFlags.UNITY_WP8 ) Fsm.Event(_event);
#endif
#if UNITY_METRO
if(_flag == platformDependentFlags.UNITY_METRO ) Fsm.Event(_event);
#endif
#if UNITY_WINRT
if(_flag == platformDependentFlags.UNITY_WINRT ) Fsm.Event(_event);
#endif
i++;
}
Finish();
}
}
}
-
Hi Jean,
I've been using this action for a while to detect different versions, however I've just tried to distinguish between a Windows Standalone build and a Unity Editor instance.
See the attachment - It never detects that it's running in the Unity Editor.
Does this work for you?
-
What build are you in? Because it will detect android if you are on a android build of Unity then call the action.
If you only want to trigger on unity editor you have to check if its the editor first, as android and editor are both returning true (most likely).
Or just if UNITY_ANDROID && !UNITY_EDITOR
-
PC, Mac, Linux Standalone build. Not really sure why you're mentioning Android at all.
My problem is that I think it should detect as UNITY_EDITOR or UNITY_EDITOR_WIN - but it doesn't (for either), it detects as UNITY_STANDALONE_WIN.
-
Ah, I was just saying that as your screenshot had android and iOS stuff in it. Good luck with your bug.
-
Hi,
I would cut this into two states.
first state you cehck just if you are in editor or not and then you transit ( if not in editor) into a new set of checks for platforms.
Bye,
Jean