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.
51 lines
923 B
51 lines
923 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; |
|
} |
|
} |
|
|
|
[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; |
|
} |
|
} |
|
} |
|
|
|
} |