Search Unity

Bug New project won't compile - Burst 1.8.2 error: The name 'Unsafe' does not exist

Discussion in 'Editor & General Support' started by gotiobg, Jan 3, 2023.

  1. gotiobg

    gotiobg

    Joined:
    May 10, 2017
    Posts:
    19
    I just downloaded Unity 2021.3.16f1 URP and created a new project. Whilst creating it, a prompt came up and asked me to go into safe mode. The following errors occurred:

    Library\PackageCache\com.unity.burst@1.8.2\Runtime\SharedStatic.cs(35,28): error CS0103: The name 'Unsafe' does not exist in the current context
    Library\PackageCache\com.unity.burst@1.8.2\Runtime\BurstString.Float.cs(1442,21): error CS0103: The name 'Unsafe' does not exist in the current context
    Library\PackageCache\com.unity.burst@1.8.2\Runtime\BurstString.Float.cs(1469,21): error CS0103: The name 'Unsafe' does not exist in the current context
    Library\PackageCache\com.unity.burst@1.8.2\Runtime\BurstString.Float.cs(1594,17): error CS0103: The name 'Unsafe' does not exist in the current context
    Library\PackageCache\com.unity.burst@1.8.2\Runtime\BurstString.Float.cs(1651,17): error CS0103: The name 'Unsafe' does not exist in the current context

    I don't think the fault is with the package directly. I had to rollback my Windows 10 to a previous version due to graphics driver failure. I had Unity 2021.3.16f1 installed and rollbacked to a point where I had only 2021.3.11f installed. I think it's a Windows registry error or something is cached.
     
  2. gotiobg

    gotiobg

    Joined:
    May 10, 2017
    Posts:
    19
    I will try to use Unity 2021.3.15f1 to see if it works
     
  3. gotiobg

    gotiobg

    Joined:
    May 10, 2017
    Posts:
    19
    Installed 2021.3.15f1 and created a new 3D URP Core project. The above errors are gone. The project works normally.

    However, when downgrading my existing project from 2021.3.16f1 to 2021.3.15f1 there are some errors. Would have been good if I had a backup right now. Will try to fix it. If it doesn't work I'll just make a new project and import all of my assets.
     
  4. gotiobg

    gotiobg

    Joined:
    May 10, 2017
    Posts:
    19
    I'm still trying to fix the project. I tried making a new project and copied all assets but all my presets are gone and the errors persist. I'm currently getting this error when running the game in the editor:

    DllNotFoundException: UnityOpenXR assembly:<unknown assembly> type:<unknown type> member:(null)
    UnityEngine.XR.OpenXR.OpenXRLoaderBase.Initialize () (at Library/PackageCache/com.unity.xr.openxr@1.5.3/Runtime/OpenXRLoader.cs:177)
    UnityEngine.XR.Management.XRManagerSettings.InitializeLoaderSync () (at Library/PackageCache/com.unity.xr.management@4.2.0/Runtime/XRManagerSettings.cs:190)
    UnityEngine.XR.Management.XRGeneralSettings.InitXRSDK () (at Library/PackageCache/com.unity.xr.management@4.2.0/Runtime/XRGeneralSettings.cs:175)
    UnityEngine.XR.Management.XRGeneralSettings.AttemptInitializeXRSDKOnLoad () (at Library/PackageCache/com.unity.xr.management@4.2.0/Runtime/XRGeneralSettings.cs:148)

    Which leads to DiagnosticReport.StartReport();
    I assume I need to reload the OpenXR plugin somehow. I tried to rebuild the solution from Visual Studio but the error is still present.

    Any help will be much appreciated
     
  5. gotiobg

    gotiobg

    Joined:
    May 10, 2017
    Posts:
    19
    Finally fixed it.

    Unity caches packages in "C:\Users\User\AppData\Local\Unity\cache\packages\packages.unity.com"
    I deleted the folder "com.unity.xr.openxr@1.5.3" which was 20.2MB at the time.
    After I went back into Unity, a new folder with the same name was created with a new size of 28.4MB. Which means the error was with the cached instance of the package.
    With this new instance, I restarted Unity and I could run the game without errors. Even my HMD connection works now.

    Hope this helps someone
     
    jayb7, lukasz13, pahe and 1 other person like this.
  6. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    I got the same error with Unity 2022.2.2f1. Even I deleted package cache from users folder and project library folder, I still get this error. How can I fix this?
     
    plan-systems likes this.
  7. plan-systems

    plan-systems

    Joined:
    Mar 8, 2020
    Posts:
    44
    Seeing this as well since 2022.2 came out consistently on OS 10.14. Would be great to be using 2022.2, but this is a show stopper.
     
  8. voxelltech

    voxelltech

    Joined:
    Oct 8, 2019
    Posts:
    44
    yeah, it is still happening even in Unity 2022.2.7f1
     
  9. plan-systems

    plan-systems

    Joined:
    Mar 8, 2020
    Posts:
    44
    It looks like Unity has iterated on C# in 2222.2 such that `Unsafe` dll support that previously worked no longer does. However it appears that a newer version of Unsafe should be used instead.

    If you're like me and not interested in dealing with nuget, rename the .nuget download to .zip, unzip it, and move lib/netstandard2.0/System.Runtime.CompilerServices.Unsafe.dll into your Assets dir.

    I did the Unity 2022.2 upgrade from there.
     
    Last edited: Mar 16, 2023
  10. voxelltech

    voxelltech

    Joined:
    Oct 8, 2019
    Posts:
    44
    Hi, I was able to solve this issue also by upgrading Burst package to 1.8.3 and restart the editor.
     
  11. Pingman12

    Pingman12

    Joined:
    Jul 29, 2023
    Posts:
    3
    I am using unity 2022.3.6f1 and whenever i tried to open a 3D URP project is asks to enable to safe mode and pops up with too many errors how can i fix that i tried to find solution but can't find nay please help.....
     

    Attached Files:

    • bug.png
      bug.png
      File size:
      260.3 KB
      Views:
      109