"...uses unsafe Pointers which is not allowed..." Despite using [NativeDisableUnsafePtrRestriction]

Hey everyone.

Despite using “[NativeDisableUnsafePtrRestriction]” I still have an error.

I am trying to do something pretty simple, but I still keep getting the same error when running my game.

All I want to do is simply pass my “TransformAccessArray” from the main thread to the Job system “IJobParallelForTransform”.

At first, I found out I need to add “[NativeDisableUnsafePtrRestriction]” but after adding it, I still keep getting the same error:

"…m_TransformArray uses unsafe Pointers which is not allowed. Unsafe Pointers can lead to crashes and no safety against race conditions can be provided.
If you really need to use unsafe pointers, you can disable this check using [NativeDisableUnsafePtrRestriction]."

Also adding “[ReadOnly]” didn’t help. All I need is to read a certain data from a certain transform.
This is the line inside the IJobParallelForTransform:

[NativeDisableUnsafePtrRestriction] public TransformAccessArray transformArray;

Please, can someone give me a hand on this?

Hi, key here is that TransformAccessArray is passed via Execute parameter automatically as TransformAccess.
So you don’t need / can’t pass it manually like that.

See example here:
https://docs.unity3d.com/ScriptReference/Jobs.IJobParallelForTransform.html

I’m facing this same issue, but I’m wanting to dispose of the transform access array in a job (so that it’s automatically disposed). Any ideas?