diff --git a/Assets/Cryville/Crtr/Components/SectionalGameObject.cs b/Assets/Cryville/Crtr/Components/SectionalGameObject.cs index 8a9961a..71e2c9c 100644 --- a/Assets/Cryville/Crtr/Components/SectionalGameObject.cs +++ b/Assets/Cryville/Crtr/Components/SectionalGameObject.cs @@ -19,7 +19,7 @@ namespace Cryville.Crtr.Components { public SectionalGameObject() { SubmitProperty("partial", new PropOp.Boolean(v => part = Part.idle)); - SubmitProperty("part", new PropOp.Enum(v => part = v)); + SubmitProperty("part", new PropOp.Enum(v => part = v, v => (Part)v)); } protected override void OnDestroy() { diff --git a/Assets/Cryville/Crtr/Components/SpritePlane.cs b/Assets/Cryville/Crtr/Components/SpritePlane.cs index 9148db4..fa8103c 100644 --- a/Assets/Cryville/Crtr/Components/SpritePlane.cs +++ b/Assets/Cryville/Crtr/Components/SpritePlane.cs @@ -61,7 +61,7 @@ namespace Cryville.Crtr.Components { public class SpritePlane : SpriteBase { public SpritePlane() { SubmitProperty("frame", new PropOp.String(v => Frame = v)); - SubmitProperty("fit", new PropOp.Enum(v => Fit = v)); + SubmitProperty("fit", new PropOp.Enum(v => Fit = v, v => (FitMode)v)); SubmitProperty("opacity", new PropOp.Float(v => Opacity = v)); } diff --git a/Assets/Cryville/Crtr/PropOp.cs b/Assets/Cryville/Crtr/PropOp.cs index 466dc74..f0e3df4 100644 --- a/Assets/Cryville/Crtr/PropOp.cs +++ b/Assets/Cryville/Crtr/PropOp.cs @@ -72,19 +72,21 @@ namespace Cryville.Crtr { public class Enum : PropOp { readonly static Dictionary _cache = new Dictionary(); readonly Action _cb; - public Enum(Action cb) { + readonly Func _caster; + public Enum(Action cb, Func caster) { if (!typeof(T).IsEnum) throw new ArgumentException("Type is not enum"); var names = typeof(T).GetFields(BindingFlags.Public | BindingFlags.Static); for (int i = 0; i < names.Length; i++) _cache[IdentifierManager.SharedInstance.Request(names[i].Name)] = Convert.ToInt32(names[i].GetValue(null)); _cb = cb; + _caster = caster; } protected override void Execute() { int result = 0; for (int i = 0; i < LoadedOperandCount; i++) result |= _cache[GetOperand(0).AsIdentifier()]; - _cb((T)(object)result); + _cb(_caster(result)); } } public class BeatTime : PropOp {