question

marck0zz-3254 avatar image
1 Vote"
marck0zz-3254 asked ·

How to integrate windows APIs to my unity app???

Hello all!!!

I'm trying to migrate my unity Windows standalone app to UWP in order to put it on the Windows Store. I have been able to build my app for my Windows 10 desktop and test it but still have some APIs that have to remove-replace in order to pass succesfully the Certification app and be able to submit it to the store, for example my old file manager to open-save files that use Windows.forms and replace it for this:

https://docs.microsoft.com/en-us/windows/uwp/files/quickstart-using-file-and-folder-pickers

Plus I would like to take advantage from the store and sell subscrption in my app and integrate somethinf like this:

https://docs.microsoft.com/en-us/windows/uwp/monetize/enable-subscription-add-ons-for-your-app

The problem with both solutions is that I don't know how to integrate those Windows APIs to my project in Unity.

I have trying something like this:

     public void OpenFile()
     {
         FilePicker();
     }
    
     async void FilePicker()
     {
    
 #if ENABLE_WINMD_SUPPORT
         var picker = new Windows.Storage.Pickers.FileOpenPicker();
         picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
         picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
         picker.FileTypeFilter.Add(".jpg");
         picker.FileTypeFilter.Add(".jpeg");
         picker.FileTypeFilter.Add(".png");
    
         Windows.Storage.StorageFile file = await picker.PickSingleFileAsync();
         if (file != null)
         {   
             Debug.Log(file.Name);
         }
         else
         {
             Debug.Log("Operation cancelled");
         }
 #endif

But with no good results at all. Is there a guide or something on good practices or how to integrate those APIs in Unity?

I will appreciate any help. Thank you in advance.

windows-uwppartner-center-generaldotnet-gamedev
· 1
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I'm hetting this error: "Assets\Scripts\FileManagerUWP.cs(39,54): error CS1929: 'IAsyncOperation<StorageFile>' does not contain a definition for 'GetAwaiter' and the best extension method overload 'AwaitExtensions.GetAwaiter(Process)' requires a receiver of type 'Process'" but this doc: https://docs.microsoft.com/en-us/windows/uwp/threading-async/call-asynchronous-apis-in-csharp-or-visual-basic, says that the "FileOpenPicker.PickSingleFileAsync" has an "StorageFile" result type, so for me it seems like "await" operator it's not working as it should in an "UWP buid" but in an "Unity way". I don't know what I'm missing

0 Votes 0 ·

0 Answers