netpyoung / unity.webp

:art: WebP made easy for Unity3d
https://netpyoung.github.io/unity.webp/
MIT License
237 stars 28 forks source link

the name 'unsafe' does not exist in current context #52

Closed strangeways-dev closed 11 months ago

strangeways-dev commented 1 year ago

The package is not working even after following the installation instructions from the openUPM: https://openupm.com/packages/com.netpyoung.webp/#modal-manualinstallation

Here's what I get in the console after installing the package:

Library\PackageCache\com.netpyoung.webp@0.3.9\Runtime\NativeLibwebpdemux.cs(112,17): error CS0103: The name 'Unsafe' does not exist in the current context Library\PackageCache\com.netpyoung.webp@0.3.9\Runtime\NativeLibwebpdemux.cs(141,17): error CS0103: The name 'Unsafe' does not exist in the current context

How can I fix this?

netpyoung commented 1 year ago

hi @imineti

For package install needs System.Runtime.CompilerServices.Unsafe.dll.

But rather than use .package to install unity.webp, I recommand to use upm

You can find manifest.json from {gameproject}/Packages/manifest.json. than modify to add

{
  "dependencies": {
    "com.netpyoung.webp": "https://github.com/netpyoung/unity.webp.git?path=unity_project/Assets/unity.webp#0.3.9",
    "org.nuget.system.runtime.compilerservices.unsafe": "6.0.0"
  },
  "scopedRegistries": [
    {
      "name": "Unity NuGet",
      "url": "https://unitynuget-registry.azurewebsites.net",
      "scopes": [
        "org.nuget"
      ]
    }
  ]
}

https://github.com/netpyoung/unity.webp#using-upm