{"record":{"id":"ffee76f61bb52db9","repo":"stride3d/stride","slug":"typeof-unmanagedarray-t-type-is-not-supported-ffee76","errorCode":null,"errorMessage":"{ typeof(UnmanagedArray<T>) } type is not supported.","messagePattern":"(.+?) type is not supported\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Physics/HeightStickArraySourceFromHeightmap.cs","lineNumber":62,"sourceCode":"\n            if (typeOfT == typeof(float))\n            {\n                if (Heightmap.Floats == null) throw new InvalidOperationException($\"{ nameof(Heightmap.Floats) } is a null.\");\n                heights = (T[])(object)Heightmap.Floats;\n            }\n            else if (typeOfT == typeof(short))\n            {\n                if (Heightmap.Shorts == null) throw new InvalidOperationException($\"{ nameof(Heightmap.Shorts) } is a null.\");\n                heights = (T[])(object)Heightmap.Shorts;\n            }\n            else if (typeOfT == typeof(byte))\n            {\n                if (Heightmap.Bytes == null) throw new InvalidOperationException($\"{ nameof(Heightmap.Bytes) } is a null.\");\n                heights = (T[])(object)Heightmap.Bytes;\n            }\n            else\n            {\n                throw new NotSupportedException($\"{ typeof(UnmanagedArray<T>) } type is not supported.\");\n            }\n\n            var heightsLength = heights.Length;\n            if (heightStickArrayLength < heightsLength) throw new ArgumentException($\"{ nameof(heightStickArray) }.{ nameof(heightStickArray.Length) } is not enough to copy.\");\n\n            heightStickArray.Write(heights, index * Unsafe.SizeOf<T>(), 0, heightsLength);\n        }\n\n        public bool Match(object obj)\n        {\n            var other = obj as HeightStickArraySourceFromHeightmap;\n\n            if (other == null)\n            {\n                return false;\n            }\n\n            return other.Heightmap == Heightmap;","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Physics/HeightStickArraySourceFromHeightmap.cs#L44-L80","documentation":"CopyTo<T> only supports T of short or byte, matching the buffers stored on Heightmap (Shorts/Bytes). Any other T (e.g. float, int, UnmanagedArray<T>) falls into the else branch and throws NotSupportedException, because the engine's heightstick array only accepts those element types.","triggerScenarios":"Calling heightStickArraySource.CopyTo<float>(...) or CopyTo<int>(...) — any generic argument other than short or byte.","commonSituations":"Developers assume float heightmaps are supported (Bullet heightfields are short/byte) and pass the float array type directly.","solutions":["Call CopyTo<short> or CopyTo<byte> to match the Heightmap's stored buffer type.","If height data is float, quantize it to short or byte (apply HeightScale/HeightOffset) and store in Heightmap.Shorts/Bytes first.","Inspect Heightmap.HeightType and dispatch the CopyTo generic argument accordingly."],"exampleFix":"// before\nsource.CopyTo<float>(stickArray, 0); // NotSupportedException\n// after\nsource.CopyTo<short>(stickArray, 0); // matches heightmap.HeightType == HeightfieldTypes.Short","handlingStrategy":"type-guard","validationCode":"if (typeof(T) != typeof(short) && typeof(T) != typeof(byte))\n    throw new InvalidOperationException(\"CopyTo only supports short or byte.\");","typeGuard":"bool IsSupportedHeightType<T>() => typeof(T) == typeof(short) || typeof(T) == typeof(byte);","tryCatchPattern":"try { source.CopyTo<T>(stickArray, index); }\ncatch (NotSupportedException) { /* fall back to short/byte conversion */ }","preventionTips":["Remember Bullet heightstick arrays only support short and byte sample types.","Convert float height data to short/byte with scale/offset before use.","Match T to Heightmap.HeightType."],"tags":["physics","generics","unsupported-type"],"backgroundTag":"unsupported-operation","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}