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
996 B
56 lines
996 B
using UnityEngine; |
|
using System.Collections; |
|
|
|
namespace Fungus |
|
{ |
|
|
|
public class FloatVariable : Variable |
|
{ |
|
protected float floatVal; |
|
|
|
public float Value |
|
{ |
|
get { return (scope == VariableScope.Local) ? floatVal : GlobalVariables.GetFloat(key); } |
|
set { if (scope == VariableScope.Local) { floatVal = value; } else { GlobalVariables.SetFloat(key, value); } } |
|
} |
|
|
|
public override void OnReset() |
|
{ |
|
Value = 0; |
|
} |
|
|
|
public override string ToString() |
|
{ |
|
return Value.ToString(); |
|
} |
|
} |
|
|
|
[System.Serializable] |
|
public struct FloatData |
|
{ |
|
[SerializeField] |
|
public FloatVariable floatRef; |
|
|
|
[SerializeField] |
|
public float floatVal; |
|
|
|
public float Value |
|
{ |
|
get { return (floatRef == null) ? floatVal : floatRef.Value; } |
|
set { if (floatRef == null) { floatVal = value; } else { floatRef.Value = value; } } |
|
} |
|
|
|
public string GetDescription() |
|
{ |
|
if (floatRef == null) |
|
{ |
|
return floatVal.ToString(); |
|
} |
|
else |
|
{ |
|
return floatRef.key; |
|
} |
|
} |
|
} |
|
|
|
} |