LevelNameToString.cs
Description: Returns current level's name as a String
Example: Using it with <Load Level> (from string) - can be very helpful when it comes to working with multiple scenes.
With this action you can store name of a previously played level to go back to it later when needed (sub-locations / interiors etc) or to simply restart scene.
// (c) Copyright HutongGames, LLC 2010-2011. All rights reserved.
// micro script by Andrew Raphael Lukasik
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Level)]
[Tooltip("Returns current level's name as a string.")]
public class LevelNameToString : FsmStateAction
{
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmString stringVariable;
[RequiredField]
private FsmString stringValue;
public override void Reset()
{
stringVariable = null;
stringValue = null;
}
public override void OnEnter()
{
DoSetStringValue();
Finish();
}
void DoSetStringValue()
{
if (stringVariable == null) return;
stringValue = Application.loadedLevelName;
stringVariable.Value = stringValue.Value;
}
}
}