stride3d/stride · error · NotSupportedException
type is not supported.
Error message
{ typeof(UnmanagedArray<T>) } type is not supported. What it means
FloatHeightStickArraySource.CopyTo only supports filling UnmanagedArray<float> buffers; it fills with the InitialHeight float. Passing any other element type T throws NotSupportedException naming the unsupported UnmanagedArray<T> type.
Solutions
- Pass an UnmanagedArray<float> to FloatHeightStickArraySource.CopyTo.
- Use the correct heightstick source type (short/byte variants) if your heightfield uses quantized heights.
- Convert the destination buffer to UnmanagedArray<float> before copying.
Example fix
// before UnmanagedArray<short> heights = ...; floatSource.CopyTo(heights, 0); // throws // after UnmanagedArray<float> heights = new UnmanagedArray<float>(width * height); floatSource.CopyTo(heights, 0);
Defensive patterns
Strategy: type-guard
Validate before calling
if (heightStickArray is UnmanagedArray<float>)
source.CopyTo(heightStickArray, 0); Type guard
static bool IsFloatHeightArray<T>(UnmanagedArray<T> a) where T : struct => a is UnmanagedArray<float>;
Try / catch
try { source.CopyTo(heightStickArray, 0); }
catch (NotSupportedException) { /* use the short/byte heightstick source instead */ } Prevention
- Use FloatHeightStickArraySource only with UnmanagedArray<float>
- Match source type to the heightfield's HeightType
- Centralize heightstick buffer creation in one typed helper
When it happens
Trigger: Calling FloatHeightStickArraySource.CopyTo with an UnmanagedArray<short>, UnmanagedArray<byte>, or any non-float element type.
Common situations: Mixing up heightstick sources: short/byte heightstick arrays are meant to be populated from ShortsHeightStickArraySource/BytesHeightStickArraySource, not the float variant; refactoring changed the array element type.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- type is not supported.
- type is not supported.
- heightStickArray
- is a null.
- parameters should be greater than or equal to 2.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/a873865c21f42820.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Physics/FloatHeightStickArraySource.cs:44
/// <summary>
/// The value to fill the height stick array.
/// </summary>
[DataMember(30)]
public float InitialHeight { get; set; } = 0;
public bool IsValid() => HeightmapUtils.CheckHeightParameters(HeightStickSize, HeightType, HeightRange, HeightScale, false) &&
MathUtil.IsInRange(InitialHeight, HeightRange.X, HeightRange.Y);
public void CopyTo<T>(UnmanagedArray<T> heightStickArray, int index) where T : struct
{
if (heightStickArray == null) throw new ArgumentNullException(nameof(heightStickArray));
if (heightStickArray is UnmanagedArray<float> unmanagedArray)
{
unmanagedArray.Fill(InitialHeight, index, HeightStickSize.X * HeightStickSize.Y);
}
else
{
throw new NotSupportedException($"{ typeof(UnmanagedArray<T>) } type is not supported.");
}
}
public bool Match(object obj)
{
var other = obj as FloatHeightStickArraySource;
if (other == null)
{
return false;
}
return other.HeightStickSize == HeightStickSize &&
other.HeightRange == HeightRange &&
Math.Abs(other.InitialHeight - InitialHeight) < float.Epsilon;
}
}
}View on GitHub (pinned to 96fad776d2)