playMaker

Author Topic: GetLayerIndexFromName  (Read 881 times)

giyomu

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 108
    • View Profile
    • blog
GetLayerIndexFromName
« on: July 04, 2011, 11:31:37 PM »
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;
}
}