Merge pull request #78 from Saso222/canary

Setter to AtomReference's Value was added
This commit is contained in:
Oliver Biwer 2019-11-11 21:02:43 +01:00 committed by GitHub
commit e2faf2e3d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,3 +1,4 @@
using System;
using UnityEngine;
namespace UnityAtoms
@ -56,7 +57,7 @@ namespace UnityAtoms
}
/// <summary>
/// Get the value for the Reference.
/// Get or set the value for the Reference.
/// </summary>
/// <value>The value of type `T`.</value>
public T Value
@ -72,6 +73,25 @@ namespace UnityAtoms
return _value;
}
}
set
{
switch (_usage)
{
case (AtomReference.Usage.Variable):
{
_variable.Value = value;
break;
}
case (AtomReference.Usage.Value):
{
_value = value;
break;
}
case (AtomReference.Usage.Constant):
default:
throw new NotSupportedException("Can't reassign constant value");
}
}
}
public static implicit operator T(AtomReference<T, V, C> reference)