UnityEngine.WSA Not found

Hello,

I am building a Windows Store application using the below script. I am getting error Error 5 The type or namespace name ‘WSA’ does not exist in the namespace ‘UnityEngine’ (are you missing an assembly reference?) I am still learning Unity and C#, but I once had the same issue in another app but some how I got it working. How do I get the WSA added into the UnityEngine?

Thanks,

John

code:

using UnityEngine;
#if UNITY_WINRT
using System;
using System.Collections;
using System.Threading;
using System.IO;



/// <summary>
/// Windows specific and interop between Unity and Windows Store or Windows Phone 8
/// </summary>
public static class WindowsGateway
{
    //notes
    static WindowsGateway()
    {
#if UNITY_METRO
        // unity now supports handling size changed in 4.3
        //UnityEngine.WSA.Application.windowSizeChanged += WindowSizeChanged;
        UnityEngine.WSA.Application.windowSizeChanged += WindowSizeChanged;
#endif

        // create blank implementations to avoid errors within editor
        UnityLoaded = delegate { };

        //blank implementation for our Share function
        ShareHighScore = delegate { };

    }

    /// <summary>
    /// Called from Unity when the app is responsive and ready for play
    /// </summary>
    public static Action UnityLoaded;

    //called when we want to Share a high score
    public static Action ShareHighScore;

#if UNITY_METRO
    /// <summary>
    /// Deal with windows resizing
    /// </summary>
    public static void WindowSizeChanged(int width, int height)
    {
        if (width <= GameManager.Instance.startingScreenSize.Width / 2)
        {
            //GameManager.Instance.paused();
            Pause.paused = true;

        }
        else
        {
            //GameManager.Instance.unpaused();
            Pause.paused = false;
        }

    }
#endif

}

#endif

Using “Unity Pro for Windows” 4.5.5.p5.

I’m trying a hack workaround. I don’t like it but there no other option.

The problem is that even though the Unity Editor is setup for the Windows Store platform, XAML C# Solution Type and Phone 8.1 SDK, the wrong UnityEngine.dll is deployed to "[Unity project dir]\Library\UnityAssemblies" directory. The UnityEngine.dll found in the directory does not contain the UnityEngine.WSA namespace. I found the correct .dll file in the following path: "C:\Program Files (x86)\Unity\Editor\Data\PlaybackEngines\metrosupport\Tools" directory.
So what else could I do, in the UnityAssemblies directory, I renamed the existing UnityEngine.dll and UnityEngine.xml files, and copied the correct .dll file to the UnityAssemblies directory. A correct UnityEngine.xml file gets generated in when rebuilding Unity Editor code.

I’m going to have do this copy hack every time I re-import all.

Please, could we get some real Unity support/help here.

John W.

Hi,

I used the same workaround you used from above. I just pointed/added in the dll(UnityEngine.dll)in Unity program files folder. I got it working.

Sorry for the late reply long day at work.

John L

Assets/Utilities/Scripts/Anchor.cs(5,22): error CS0234: The type or namespace name WSA' does not exist in the namespace UnityEngine.VR’. Are you missing an assembly reference?

The above is the problem I encountered.But i can not understand the answer that mentioned above how to implement.I select the universal windows platform and unity version is 2017.4.1.can you help me? thanks very much!,i meet the same problem,but i can not understand how the above answer is implemented,can you answer for me? thanks!

10 years… :older_adult:

For Unity 2020.3 (2020.3.41f1)
Ps: I have this error in a legacy Hololens project (Unity XR etc)

Solution:

  • Add Universal Windows Platform module (using UnityHub)
  • Switch Platform to Universal Windows Platform
  • Now UnityEngine.WSA is avaiable.