Unity: use UWP project in unity windows standalone application - c#

I am making a windows standalone application using unity.
I want to record video from PC webcam and save it locally. The only solution that I found is a UWP project that records video and saves it to PC.
I want to know if there is a way to use this UWP solution in my windows standalone application.
For C# projects (not UWP), I build it to dll and use it as dll in my application.
I need to find a way to do just like this with UWP project.
Edit 1:
I tried Unity VideoCapture Example in both editor and build. In unity editor, the application runs without errors but it didn't enter to this function "VideoCapture.CreateAsync()", as they said it didn't work with the editor.
When I tried to build to windows standalone build, it gives me this error :
"Assets/Scripts/Controllers/Other/VideoCaptureExample.cs(4,26): error CS0234: The type or namespace name 'WebCam' does not exist in the namespace 'UnityEngine.XR.WSA'. Are you missing an assembly reference?"

If you are using the HoloToolkit / MRTK, you had best delete that folder and use the newer asset, or better yet, use the Master Branch which has more fixes in it.
Or you can try update your Unity to 2017.2 and the sample works when testing on my machine. 

Related

Create A DLL to work on a solution targeting Master ARM64? (Hololens 2)

I develop applications targeting the Hololens 2 platform (mixed reality).
The general idea of the application I am trying to build is using a point cloud registration algorithm, which targets a previously scanned model on one hand and the visible point cloud generated by the Hololens' SceneUnderstanding ability on the other.
My main problem is that all the different implementations that I found of the algorithm are using libraries (DLLs) that:
Uses a lower-level language (C++) than the C# scripting language used in Unity's scripts.
Are not targeting the needed configuration and architecture needed for deploying an application on the Hololens 2 (Master configuration, ARM64 architecture).
In the process of trying to generate that kind of library myself (using visual studio 2019 to build "Dynamic-Link Library with Exports [DLL]"),
I created the simplest library in C++ - A single function that returns an integer (without the dependency of any other library). Obviously, when targeting the Unity Editor application it was easy to use the library's function from the C# script attached to the Unity project, but when I try to convert the solution's configuration and architecture to Master ARM64, building a Visual Studio solution and deploying the application on the Hololens 2 generates a script error: "Unable to load DLL '<dll_name>': The specified module could not be found."
I can think of two major reasons that will cause this problem:
The program can not find the library needed for function execution,
JUST BECAUSE the location of the library is not correct (I have NO IDEA
where the library should be placed in the solution hierarchy).
I am probably not using the right technique for converting the library to the correct target solution properties (in addition of the previous scenario)
(and as well, I have no idea what is the correct procedure for achieving correct targeting properties)
Using: Visual Studio 2019, Unity 2019.4.1f1, Hololens 2nd generation
It would mean a lot to hear from anyone who have encountered any sort of similar problem, thank you in advance!
To add a custom DLL to a Unity project for HoloLens 2, you have to copy the DLL to a folder called Assets/Plugins/WSAPlayer/ARM64 in your project hierarchy in Unity. Then, you should also make sure that the correct Platform settings are specified for the Plugin in the Inspector, i.e., SDK should be set to UWP and CPU to ARM64:
This git repo has an example of this (DLL and Unity project).
Note that the DLL has to be compatible with Universal Windows Platform (UWP), so when creating a new library with Visual Studio, you should select either the DLL (Universal Windows) or Windows Runtime Component project templates as your starting point.
If you add any dependencies to your DLL, e.g., for point cloud registration, you will also have to build those libraries for UWP / ARM64, and add those DLLs to the same folder as well!

How do you add manifest files to UWP projects that Unity3D builds?

I am porting a game to Windows 10 and Xbox One, which requires that I have certain manifest files in my UWP app for defining the capabilities and socket usage of the application.
I understand the uses of these manifest files; however, I do not understand how I am able to configure the manifests that are built or injected into UWP applications that Unity3D creates when building.
Specifically, I need to add the file networkmanifest.xml to my UWP app to define socket usage for use with Xbox Live. Here is a link to Microsoft's documentation on the manifest file.
Research into this area has left me drawing a blank, and I'm not sure if it is because I'm fundamentally looking at this problem wrong.
There are two good options here:
Write a script that automatically gets run after the build (using OnPostprocessBuild) and copy/inject your manifest into the generated project there.
Modify the generated Visual Studio solution and commit the files you modified to your project source control. When building your game from Unity, always build on top of the same modified project. Unity will not overwrite the changes you made.

Building an UWP app from unity, using external dll built in visual studio, generates an error on the Task class

I made an UWP application in Unity for Hololens and I added in the Assets a class using Tasks (System.Threading.Tasks). The code of the class is surrounded by the compilation directive as follow:
#if WINDOWS_UWP
.... Code Here
#endif
since it needs to work only on the device.
I successfully deployed the application on the Hololens.
But when I try to move the class in an external dll, generated compiling a Class Library (Universal Windows) project in Visual studio, and I reference it in Unity, when compiling I get the following error:
... type 'Task<>' claims it is defined in 'System.Runtime', but it could not be found.
It seems that it is not using System.Threading.Tasks, but it tries to use a Task class defined in System.Runtime.
Why this happens only if the class is in an external dll and I works when the class is directly in the assets folder?
Since I need to have the code in the external dll how can I fix it?
The problem was in the minimun SDK version of the UWP library.
By default Unity uses Windows 10 (10.0; Build 10240) when building UWP applications, while the minimum version of the UWP Library was Windows 10 Creators Update (10.0; Build 15063).
Setting up the SDK minimum version of the UWP Class library in visual studio to Windows 10 (10.0; Build 10240), and reimporting the dll in Unity, solved my problem.

Not found or missing file

I am working on a cross platform Gui app using c# Visual Studio on Windows. I was hoping to port my code to linux via Monodevelop because i have tried it with another project and it worked.
However in this particular project I happen to use EasyTabs dll to create a chrome tabs on my app. The projects is error free on windows but on linux i get a dll exception error and one dll it says is missing is that of uxtheme.dll
I have tried to copy the uxtheme dll from my windows C:\Windows\System32
To my project and add it to my .csproj and even copied it to my debug and release folder. However this has not been successful. Any workable idea would do.
it looks like you are trying to run a winapi project on linux. While Monodevelop may look like it support windows envirnonment on linux os it is very important to note that not all dll and supportive windows runtime files are available. You have to look for missing dll files to fix your problem or simply write a program that does not require them at all

How combine Unity project as a Library with Android Project Application

I have read a lot about this topic, how to integrate Android App with Unity App, and it's seem to be something really strange.
I have check post like this http://www.41post.com/5292/programming/unity-and-android-create-an-unity-app-with-a-custom-layout
which is working fine. But, in this case, the developer after export Unity Project to Android Studio, he start to develop his code inside the project that Unity has created.
This is not the same thing I have to do, I need to export Unity Project, make this a module marked as a Library and be imported for another Android Project.
Making this I have achived compile but in runtime I have different erros, some erros like "Unable to find Main", I have changed gradle and recompile with ndk to recognize .so files but is not working, when I open App it's say something like "Failure to initialize! Your hardware does not support this application, sorry!" and this have no sense because this Unity app has been tested in the same device and works.
Maybe is something that can't be done, and Im just totally lost.
Has someone make this happens?
Thanks,
Regards.

Categories