Can't get AtomicSafetyHandle to work outside Editor environment

I have an assembly which makes heavy use of the AtomicSafetyHandle. Now I wanted to export a project with this assembly to a plain Win64 application, but I totally fail and my frustration level is on the limit - either I’m really just lacking something or I’m just a moron.

Everything is fine in Visual Studio and when running it out of the Editor mode, but everything goes south once I try to build it to an app - whether with Mono or IL2CPP does not make any difference.

  Assets\X\Scripts\Y.cs(64,21): error CS0246: The type or namespace name 'AtomicSafetyHandle' could not be found (are you missing a using directive or an assembly reference?)

The basic code looks somewhat like this:

using Unity.Collections.LowLevel.Unsafe;
public class A {
    private AtomicSafetyHandle m_Safety;
    public doSomething() {
                m_Safety = AtomicSafetyHandle.Create();
    }
}

The documentation says AtomicSafetyHandle become available through defining ENABLE_UNITY_COLLECTIONS_CHECKS, but it does neither say that it is enabled by default in the Editor world, nor that it is not available outside the Editor world. So I get the error above and I add the flag as scripting define symbol - nothing - it does not fix it.

I lost track of all the posts I read and all the stuff I tried previously - someone mentioned that it is enabled by default on the Editor and that enabling it as a scripting define does not work - no justification why given. I’m aware that the unity.collections have been linked up with Jobs and Burst recently, but I can’t see how this has anything todo with this problem. I have also added and removed those packages, down- and upgraded it, switched Unity versions, closed/reimported/reopened Editor and so on and so forth, no luck.

The AtomicSafetyHandle essentially seems to only exist in the Editor world, but why and if I’m wrong with that, can somebody please tell me how to enable it and why the documentation about this is so unclear?

Windows 10 x64
Unity 2020.3.30f1
VS 2019 16.11.10

bump… anyone?

The entire safety system only exists in Editor. This includes AtomicSafetyHandle.

In a standalone build, no safety checks of any kind are performed as far as I know.

1 Like