An easy to use Unity 3D library for creating illustrated Interactive Fiction games and more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1009 B

using UnityEngine;
using System.Collections;
namespace Fungus
{
public class StringVariable : Variable
{
protected string stringVal;
public string Value
{
get { return (scope == VariableScope.Local) ? stringVal : GlobalVariables.GetString(key); }
set { if (scope == VariableScope.Local) { stringVal = value; } else { GlobalVariables.SetString(key, value); } }
}
public override void OnReset()
{
Value = "";
}
public override string ToString()
{
return Value.ToString();
}
}
[System.Serializable]
public struct StringData
{
[SerializeField]
public StringVariable stringRef;
[SerializeField]
public string stringVal;
public string Value
{
get { return (stringRef == null) ? stringVal : stringRef.Value; }
set { if (stringRef == null) { stringVal = value; } else { stringRef.Value = value; } }
}
public string GetDescription()
{
if (stringRef == null)
{
return stringVal;
}
else
{
return stringRef.key;
}
}
}
}