How can I make transparent background UWP app in Unity with user32.dll?

Evan 6 Reputation points
2022-04-08T05:56:38.523+00:00

Hello. I'm developing UWP(Win10) program in Unity.

I need to develop transparent background UWP app, so I add user32.dll in script just like this

public class test : MonoBehaviour  
{  
    [DllImport("user32.dll")]  
    public static extern IntPtr GetActiveWindow();  
    ....  
  
    private void Start()  
    {  
        IntPtr hWnd = GetActiveWindow();  
        ...  
    }  
}  

but after I build my project and run, error occurs just like this

DllNotFoundException: Unable to load DLL 'user32.dll'. Tried the load the following dynamic libraries: Unable to load dynamic library 'user32.dll' because of 'Failed to open the requested dynamic library (0x06000000)  

So I changed my project setting to Windows standalone, and build it.
After that, It works perfectly.
191222-transparentapp.png

I want to make this program to UWP app, so I need to build it with user32.dll in UWP project.
Can I make transparent background UWP app in Unity with user32.dll?
If not, How can I use user32.dll in UWP project?

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
36,982 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Castorix31 82,321 Reputation points
    2022-04-08T09:59:04+00:00

    In UWP, transparent backgrounds are done with Acrylic Brushes
    See Acrylic material

    0 comments No comments