Assets\Plugins\BulletUnity\BulletSharp\Collision\GImpact\GImpactShape.cs(628,28): error…
- User
Assets\Plugins\BulletUnity\BulletSharp\Collision\GImpact\GImpactShape.cs(628,28): error CS0227: Unsafe code may only appear if compiling with /unsafe. Enable "Allow 'unsafe' code" in Player Settings to fix this error.
- Assistant
The error:
error CS0227: Unsafe code may only appear if compiling with /unsafe. Enable "Allow 'unsafe' code' in Player Settings to fix this error.means that the C# code in
GImpactShape.csis usingunsafecode blocks (for example, pointers), but the Unity project is not currently configured to allow unsafe code.How to fix this in Unity:
-
Open your project in Unity.
-
Go to
Edit>Project Settings.... -
In the Project Settings window, select Player from the list on the left.
-
Under the Other Settings section, scroll down to Configuration.
-
Look for the option labeled "Allow 'unsafe' Code" (it might be a checkbox).
-
Check the box to allow unsafe code.
-
Save and try to compile again.
Alternative: Modify the compile command if using external build system
-
- User
а можешь по русски
- Assistant
Конечно!
Ошибка:
error CS0227: Unsafe code may only appear if compiling with /unsafe. Enable "Allow 'unsafe' code" in Player Settings to fix this error.означает, что в твоём коде используются небезопасные конструкции (например, указатели), которые требуют разрешения на использование
unsafeкода при компиляции. В Unity по умолчанию такой код запрещён.
Как исправить в Unity:
-
Открой Unity и загрузи свой проект.
-
В верхнем меню выбери Edit (Правка) -> Project Settings... (Настройки проекта).
-
В открывшемся окне слева выбери пункт Player (Игрок).
-
В разделе Other Settings (Другие настройки) найди подраздел Configuration (Конфигурация).
-
Там будет опция Allow 'unsafe' Code (Разрешить небезопасный код) — поставь галочку.
-
Закрой окно и пересобери проект.
После этого ошибка должна исчезнуть, и код с
unsafeблоками успешно скомпилируется.Если что-то не понятно — спрашивай!
-