From fc04071b53b1d15df3154f4b74ed54b0eac9bf7c Mon Sep 17 00:00:00 2001 From: PopSlime Date: Sun, 6 Nov 2022 13:46:23 +0800 Subject: [PATCH] Fix number marshaling for PDT variable memory. --- Assets/Cryville/Common/Pdt/PdtVariableMemory.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/Cryville/Common/Pdt/PdtVariableMemory.cs b/Assets/Cryville/Common/Pdt/PdtVariableMemory.cs index 6fe2644..936d0da 100644 --- a/Assets/Cryville/Common/Pdt/PdtVariableMemory.cs +++ b/Assets/Cryville/Common/Pdt/PdtVariableMemory.cs @@ -46,7 +46,7 @@ namespace Cryville.Common.Pdt { /// A number. /// The span at the offset does not represent a number. public float AsNumber(int offset = 0) { - if (Type != PdtInternalType.Number) + if (Type != PdtInternalType.Number && Type != PdtInternalType.Vector) throw new InvalidCastException("Not a number"); float value; byte* ptr = (byte*)&value; @@ -62,7 +62,7 @@ namespace Cryville.Common.Pdt { /// The span at the offset does not represent a number. /// The length of the span is not sufficient. public void SetNumber(float value, int offset = 0) { - if (Type != PdtInternalType.Number) + if (Type != PdtInternalType.Number && Type != PdtInternalType.Vector) throw new InvalidCastException("Not a number"); if (Length < sizeof(float) + offset) throw new InvalidOperationException("Frame length not sufficient");