playMaker

Author Topic: GetLayerIndexFromName  (Read 3655 times)

giyomu

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 108
    • blog
GetLayerIndexFromName
« 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;
}
}