Playmaker Forum

PlayMaker Updates & Downloads => Share New Actions => Topic started by: giyomu on July 05, 2011, 02:31:37 AM

Title: GetLayerIndexFromName
Post by: giyomu on July 05, 2011, 02:31:37 AM
I sometimes need that  :)

Code: [Select]
using UnityEngine;
using HutongGames.PlayMaker;

[ActionCategory(ActionCategory.GameObject)]
[Tooltip("Get layer int value from it name")]
public class GetLayerIndexFromName : FsmStateAction
{
[Tooltip("Make sure the layer exist in your scene and that you dont misstype it name")]
public FsmString layerName;
[UIHint(UIHint.Variable)]
public FsmInt storedlayerIndex;

public override void Reset ()
{
layerName = null;
storedlayerIndex = null;
}

public override void OnEnter ()
{
DoGetIndex();
Finish();
}

void DoGetIndex()
{
storedlayerIndex.Value = LayerMask.NameToLayer(layerName.Value);
layerName = null;
}
}