error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type
c3-hoge-fuga-piyo opened this issue · comments
When installing the latest version (b2684c1) in a new project created with Unity 2022.3.21f1 or Unity 2023.3.9f1, a compile error occurs at the following location.
This did not occur at 83b455a
Library\PackageCache\com.annulusgames.lit-motion@b2684c1202\Runtime\MotionUpdateJob.cs(22,82): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('MotionData<TValue, TOptions>')
Library\PackageCache\com.annulusgames.lit-motion@b2684c1202\Runtime\MotionUpdateJob.cs(168,52): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('MotionDataCore')
It appears that this is an error that depends on the version of the Collections package.
NativeContainer has its own safety checks, which are implemented differently depending on the version of Collections. 1.x uses a reference type called DisposeSentinel to perform the checks, so NativeContainer is a managed structure, whereas in 2.x it is unmanaged because only the AtomicSafetyHandle is used. Therefore, in 1.x, the pointer cannot be obtained and an error is occurring.
The solution is to change the code to use the version with the safety check removed depending on the version of Collections. This would compromise safety, but since there are already enough checks in between, it should not be a problem.
Fixed in #118.