Hello,
As the title says, NativeHashSet is built on top of a NativeHashMap, it’s only a wrapper.
NativeHashMap accepts struct type for his generics arguments
So why NativeHashSet doesn’t do the same ?
Hello,
As the title says, NativeHashSet is built on top of a NativeHashMap, it’s only a wrapper.
NativeHashMap accepts struct type for his generics arguments
So why NativeHashSet doesn’t do the same ?
NativeHashMap also only accepts unmanaged type IRC.
Well, it does give runtime error: ArgumentException: TestSystem+MyStruct used in native collection is not blittable, not primitive, or contains a type tagged as NativeContainer
```csharp
*using System;
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.Jobs;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine;
public class TestSystem : SystemBase
{
private struct MyStruct : IEquatable
{
public object o;
public bool Equals(MyStruct other)
{
return Equals(o, other.o);
}
public override bool Equals(object obj)
{
return obj is MyStruct other && Equals(other);
}
public override int GetHashCode()
{
return (o != null ? o.GetHashCode() : 0);
}
}
protected override void OnUpdate()
{
NativeHashMap<MyStruct, byte> m = new NativeHashMap<MyStruct, byte>(0, Allocator.Temp);
}
}*
```
because you using an object inside. Unmanaged means ( in this context with burst compiler) you can’t have pointer inside your struct however struct allows pointer. Can be handy when your T argument have a blob reference inside.
Seems like an issue with BlobAssetReference itself, for some reason it is not unmanaged
indeed curious to have an answer from unity team
Bump