Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type #116

Closed
c3-hoge-fuga-piyo opened this issue Mar 20, 2024 · 2 comments
Assignees

Comments

@c3-hoge-fuga-piyo
Copy link
Contributor

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

[NativeDisableUnsafePtrRestriction] public MotionData<TValue, TOptions>* DataPtr;

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>')

static float GetEasedValue(MotionDataCore* data, float value)

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')
@AnnulusGames
Copy link
Owner

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.

@AnnulusGames AnnulusGames self-assigned this Mar 20, 2024
@AnnulusGames
Copy link
Owner

Fixed in #118.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants