Physics 0.50 - CalculateDistance with custom collector error

Hi,
with the Unity Physics 0.17 (+ Collections 0.15.0 preview 21) the following custom collector code has worked:

public struct OtherNonTriggerHitsCollector<T> : ICollector<T> where T : struct, IQueryResult
{
public NativeList<T> AllHits;
.....
public OtherNonTriggerHitsCollector(int rigidBodyIndex, float maxFraction, ref NativeList<T> allHits)
{
....
}
}

Similar to the custom collectors here in the Physics Samples:
https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/UnityPhysicsSamples/Assets/Demos/6.%20Use%20Cases/CharacterController/Scripts/CharacterControllerUtilities.cs

But with the Physics 0.50 and the Collections 1.2.3-pre.1 this gives me the error:

The type 'T' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'T' in the generic type or method 'NativeList<T>'

Is there any solution to this issue?
AFAIK the samples hasn’t been updated yet and I need this for my own things.

Try using unmanaged constraint:
public struct OtherNonTriggerHitsCollector : ICollector where T : unmanaged, IQueryResult
{…}

1 Like

It worked thank you very much :slight_smile: And can you tell me if this was documented somewhere and I missed it?