Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Windows 10 Store (WSA UWP) Xbox Live Achievements

Discussion in 'Windows' started by JohnnyWasabi, Feb 24, 2016.

  1. JohnnyWasabi

    JohnnyWasabi

    Joined:
    Jul 16, 2012
    Posts:
    43
    I'm trying to implement Xbox Live Achievements in a Win10Store app (PC only, no mobile). Is there a special set of Xbox plugins used for Windows 10 Store for this?

    I have the XboxOne platform plugins and tried to use them, but I get compile errors about not finding the classes:
    "The name `XboxOneInput' does not exist in the current context"
    "The type or namespace name `XboxOnePLM' could not be found. Are you missing a using directive or an assembly reference?"
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    Hi,

    we don't yet have equivalent plugins for Windows Store as we have on xbox. We are working on them, but we have no timelines to share yet.

    You can use the xbox live DLLs directly if you have access to them and you're up for it. Since you mentioned you have the xbox plugins, you should be able to get xbox live SDK for Windows Store from your contact at id@xbox.
     
  3. JohnnyWasabi

    JohnnyWasabi

    Joined:
    Jul 16, 2012
    Posts:
    43
    OK. Thanks. I have the XboxLive SDK for Windows Store. Any pointers on how to go about setting up and using the dll are appreciated. I found the VS solution in the SDK for the Microsoft.Xbox.Services.140.UWP.WinRT. I assume that's the one I want. There is also one for Microsoft.Xbox.Services.140.UWP.CPP. I compiled the dll and copied it into my Unity project Plugins folder. Do I need to make a C# wrapper for it that loads the dll at runtime?
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    AFAIK they're both "Microsoft.Xbox.Services.140.UWP.WinRT" and "Microsoft.Xbox.Services.140.UWP.Cpp" are identical. Which scripting backend are you using?

    If you're using .NET scripting backend, you'll need to drop DLLs files for each CPU architecture and one WinMD file (they're AnyCPU, so you don't need one per CPU architecture) into your project, and then just use the Xbox API from C# scripts like you would use any other WinRT API (by wrapping code that uses it in "#if NETFX_CORE". You can build the project with "C# projects" checkbox enabled, and by opening build VS project you'll get intellisense under that define for your scripts.
     
  5. JohnnyWasabi

    JohnnyWasabi

    Joined:
    Jul 16, 2012
    Posts:
    43
    Cool, thanks! I am using C# scripting.

    When you say 'build the project with "C# projects" checkbox enabled', do you mean the dll project? And where do I find that checkbox?
     
  6. JohnnyWasabi

    JohnnyWasabi

    Joined:
    Jul 16, 2012
    Posts:
    43
    Oh, I think you meant the "C# projects" checkbox in the Unity Editor Build Settings panel. OK, I'll try that. Thanks.
     
  7. JohnnyWasabi

    JohnnyWasabi

    Joined:
    Jul 16, 2012
    Posts:
    43
    Question: Can I use the same C# code I already had working with the Unity plugins for Xbox achievements? Or was the Plugin interface different (intermediated) from the XboxLive SDK API? I have a sinking feeling it is the latter, and I'll have to rewrite that code.
     
  8. JohnnyWasabi

    JohnnyWasabi

    Joined:
    Jul 16, 2012
    Posts:
    43
    FYI: I found a section in the XBox Live SDK docs entitled "How to Add Xbox Live support for a new or existing Unity UWP project." It describes what you said plus some more detailed instruction and examples on the code side. I'll follow that guidance and let you know if I get stuck again. :)
     
  9. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    The API will definitely be different from the xbox one Unity plugins. Good luck!
     
  10. JohnnyWasabi

    JohnnyWasabi

    Joined:
    Jul 16, 2012
    Posts:
    43
    I ran into a problem: When I turn on C# debugging when building from Unity. The resultant Visual Studio UWP solution will not build. The game project gets errors about not finding the firstpass dll and spews errors in the gamecode for unknown classes, etc.

    I tracked it down to the fact that the game project is looking for the firstpass dll in a subfolder called "Unprocessed" in the dlls target output directory (which is under the Unity project, e.g.\Game\Win10\UWP\Assembly-CSharp-firstpass\bin\x64\Master\Unprocessed) , but that folder did not exist. It does exist for the Assembly-CSharp dll but not for the Assembly-CSharp-firstpass dll.

    By building the projects one at a time (as opposed to "Build Solution") and then manually creating the "Unprocessed" subfolder and copying the firstpass dll files there, I was then able to build the game project.

    Unfortunately the resultant UWP app I created did not work correctly (unlike when I build the exact same code without the C# debugging). I'm working on figuring that out, but wanted to let you know about the issue above.
     
  11. JohnnyWasabi

    JohnnyWasabi

    Joined:
    Jul 16, 2012
    Posts:
    43
    When I try to build the solution in Debug (instead of Master) it is only able to build Assembly-CSharp-firstpass. It fails while trying to build Assembly-CSharp with this error:
     
  12. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    That usually happens if VS project somehow got into an intermediate state - did you by chance build it to a folder where another VS project already existed with different options? I'd try building it to an empty folder from Unity.
     
  13. JohnnyWasabi

    JohnnyWasabi

    Joined:
    Jul 16, 2012
    Posts:
    43
    I build to an empty folder every time. I tried it again just now to be sure, and it gets the same problem. I do see this error when I first open the VS UWP project:
    And If I switch it to x64 it reports this:
    I noticed that the "obj" folder does not exist when the project is first built from Unity. It is created the first time opening the VS UWP project in Visual Studio. VS creates the file and several others but the App.g.cs file has 0 bytes. See attached screen capture.
    ObjFolder.PNG
    The intermediatexaml folder and TempPE folders are empty.

    BTW, I also tried deleting everything in the Unity projects UWP folder before building in Unity to an empty target folder. Same issue occurs.
     
  14. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,875
    Could you copy paste build output window after doing Rebuild All ?
     
  15. JohnnyWasabi

    JohnnyWasabi

    Joined:
    Jul 16, 2012
    Posts:
    43
    Yes. There was no "Build All" option; I just did "Build Solution". I had to cut out some of it in the middle (all the errors in game code after if fails to get Assembly-CSharp-FirstPass) so it would be small enough to paste. It was even too big to upload as a file with all the errors. Here it is (also attached as text file, if that's easier for you):

     

    Attached Files:

  16. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    Is there any chance you have "Allow NuGet to restore missing packages" checkbox unchecked in your VS settings? It should be checked.

     
  17. JohnnyWasabi

    JohnnyWasabi

    Joined:
    Jul 16, 2012
    Posts:
    43
    Yes, I recall turning that off just recently when I was trying different things to get it to work. One of the messages I saw mentioned this option with instructions on how to turn it off, which made me think it could be a problem. Here is the message:
    Anyway, I just turned it back on. Mine looks a little different then yours (I'm using Visual Studio Professional 2015 Version 14.0). The check-boxes were all cleared. Now I've change them as shown in the attached image.
    NuGetOptions.PNG

    However, the Build Solution still fails. Here is the new output:
     
  18. JohnnyWasabi

    JohnnyWasabi

    Joined:
    Jul 16, 2012
    Posts:
    43
    By simply building the Assembly-CSharp project again, it succeeded without the error in the Serialization Weaver. Then I build the game project and it got the error about not finding the Assembly-FirstPass.dll in the "Unprocessed" folder. So I copied the dll to the Unprocessed folder manually, and then I was able to build the game project, but it reported this error.
    In the XboxLive instructions, it said to copy the Microsoft.Xbox.Services.winmd file, but did not say anything about copying the dll (which does not even exist in the folder they say to copy the .winmd file from; it just has a bunch of nuget packages), so I had removed the dll. But you had told me to copy the dll, so I'll try that now.
    ...
     
  19. JohnnyWasabi

    JohnnyWasabi

    Joined:
    Jul 16, 2012
    Posts:
    43
    By copying over the dll I had built from the XBoxLive SDK, it got rid of the error. Now the build output looks like this when building the game project (after building the Assembly* projects):
    But when I create the app and run it, it gets an error about serialization and fails to launch (just spews errors to the dev console).
     
  20. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    Okay, there are at least two things messed.

    First of all - Visual Studio does not respect the fact that Assembly-CSharp is supposed to depend on Assembly-CSharp-firstpass and builds them in parallel. That fails, because Assembly-CSharp-Firstpass doesn't exist yet.

    Secondly, it should definitely not look in Unprocessed folder for the above mentioned assemblies. I just tested an empty project: it did not seem to do that. Inside .csproj, it copies them directly from the directories they were built from:

    Code (csharp):
    1.   <Message Importance="high" Text="Copying unprocessed assemblies..." />
    2.   <Copy SourceFiles="@(UnprocessedFile)" DestinationFolder="$(ProjectDir)" />
    3.   <Copy SourceFiles="$(UnityProjectDir)\bin\Store 8.1\$(PlatformName)\$(ConfigurationName)\Unprocessed\Assembly-CSharp.dll" DestinationFiles="$(UnityProjectDir)\bin\Store 8.1\$(PlatformName)\$(ConfigurationName)\Assembly-CSharp.dll" />
    4.   <Copy SourceFiles="$(UnityProjectDir)\bin\Store 8.1\$(PlatformName)\$(ConfigurationName)\Unprocessed\Assembly-CSharp.pdb" DestinationFiles="$(UnityProjectDir)\bin\Store 8.1\$(PlatformName)\$(ConfigurationName)\Assembly-CSharp.pdb" Condition="Exists('$(UnityProjectDir)\bin\Store 8.1\$(PlatformName)\$(ConfigurationName)\Unprocessed\Assembly-CSharp.pdb')" />
    5.   <Copy SourceFiles="$(UnityProjectDir)\bin\Store 8.1\$(PlatformName)\$(ConfigurationName)\Unprocessed\Assembly-CSharp-firstpass.dll" DestinationFiles="$(UnityProjectDir)\bin\Store 8.1\$(PlatformName)\$(ConfigurationName)\Assembly-CSharp-firstpass.dll" />
    6.   <Copy SourceFiles="$(UnityProjectDir)\bin\Store 8.1\$(PlatformName)\$(ConfigurationName)\Unprocessed\Assembly-CSharp-firstpass.pdb" DestinationFiles="$(UnityProjectDir)\bin\Store 8.1\$(PlatformName)\$(ConfigurationName)\Assembly-CSharp-firstpass.pdb" Condition="Exists('$(UnityProjectDir)\bin\Store 8.1\$(PlatformName)\$(ConfigurationName)\Unprocessed\Assembly-CSharp-firstpass.pdb')" />
    Do the MSBuild commands in your .csproj file look different?

    That brings my next question: are you modifying the generated projects in any way (like adding or removing additional references) after unity creates them?

    Lastly, for .winmd and .dll files: you need to copy one .winmd file to your Unity project (it will be marked as AnyCPU), and copy all the .dll files from the respective CPU dependent architecture folders into separate folders within your Unity project. You also need to mark the appropriate DLLs with the correct CPU setting. If I remember correctly, there's two DLLs in total for each CPU architecture: one for xbox live services and another one called something like "CppRest140Something.dll".
     
  21. JohnnyWasabi

    JohnnyWasabi

    Joined:
    Jul 16, 2012
    Posts:
    43
    So I should build the Assembly-CSharp-firstpass project first, then do Build All. OK.

    My .csproj copy commands do look different:
    Code (CSharp):
    1. <Message Importance="high" Text="Copying unprocessed assemblies..." />
    2.   <Copy SourceFiles="@(UnprocessedFile)" DestinationFolder="$(ProjectDir)" />
    3.   <Copy SourceFiles="$(UnityProjectDir)\UWP\Assembly-CSharp\bin\$(PlatformName)\$(ConfigurationName)\Unprocessed\Assembly-CSharp.dll" DestinationFiles="$(UnityProjectDir)\UWP\Assembly-CSharp\bin\$(PlatformName)\$(ConfigurationName)\Assembly-CSharp.dll" />
    4.   <Copy SourceFiles="$(UnityProjectDir)\UWP\Assembly-CSharp\bin\$(PlatformName)\$(ConfigurationName)\Unprocessed\Assembly-CSharp.pdb" DestinationFiles="$(UnityProjectDir)\UWP\Assembly-CSharp\bin\$(PlatformName)\$(ConfigurationName)\Assembly-CSharp.pdb" Condition="Exists('$(UnityProjectDir)\UWP\Assembly-CSharp\bin\$(PlatformName)\$(ConfigurationName)\Unprocessed\Assembly-CSharp.pdb')" />
    5.   <Copy SourceFiles="$(UnityProjectDir)\UWP\Assembly-CSharp-firstpass\bin\$(PlatformName)\$(ConfigurationName)\Unprocessed\Assembly-CSharp-firstpass.dll" DestinationFiles="$(UnityProjectDir)\UWP\Assembly-CSharp-firstpass\bin\$(PlatformName)\$(ConfigurationName)\Assembly-CSharp-firstpass.dll" />
    6.   <Copy SourceFiles="$(UnityProjectDir)\UWP\Assembly-CSharp-firstpass\bin\$(PlatformName)\$(ConfigurationName)\Unprocessed\Assembly-CSharp-firstpass.pdb" DestinationFiles="$(UnityProjectDir)\UWP\Assembly-CSharp-firstpass\bin\$(PlatformName)\$(ConfigurationName)\Assembly-CSharp-firstpass.pdb" Condition="Exists('$(UnityProjectDir)\UWP\Assembly-CSharp-firstpass\bin\$(PlatformName)\$(ConfigurationName)\Unprocessed\Assembly-CSharp-firstpass.pdb')" />
    I have a script that makes 2 changes to the project with OnPostProcessBuild method:
    1. It modifies MainPage.xaml.cs to fix a texture bug by adding this line of code:
    after this line of code
    2. It modifies Package.appxmanifest to specify languages that the game supports by replacing the default:
    with this list:
    I've attached the PostBuild script that I use. It is extended from a file I found in the forums to fix a bug in an older version of Unity that messed up a version number (which is now commented out because the bug was fixed).

    I don't make any other changes. After I build it in Unity, I double click the solution file to launch VS, then change the platform to x64 (from ARM), then build. The configuration is Debug.
     

    Attached Files:

  22. JohnnyWasabi

    JohnnyWasabi

    Joined:
    Jul 16, 2012
    Posts:
    43
    JFYI, since we haven't even gotten to this step yet, but I did I make a change to the code that builds the store app. This was to get around a bug that was triggered by my project being so huge. The app-build process was trying to hold all project files in memory instead of just the code files that needed building. Here is the change Microsoft had me make:

     
  23. JohnnyWasabi

    JohnnyWasabi

    Joined:
    Jul 16, 2012
    Posts:
    43
    Regarding the dlls. In my most recent restart from scratch, I failed to copy over the cpprest140_uwp_2_6.dll and related files. I did have them in a previous attempt (but there were probably other things wrong that time). I'm sorting that out now and will try another build.
     
  24. JohnnyWasabi

    JohnnyWasabi

    Joined:
    Jul 16, 2012
    Posts:
    43
    I've described my DLL setup below. Is this correct?
    Code (CSharp):
    1. Assets/Plugins/XboxLive/
    2.     02/24/2016  05:31 PM           135,168 Microsoft.Xbox.Services.winmd
    3.     WSA/  
    4.         x64/
    5.             Casablanca/
    6.                 02/25/2016  06:41 PM         1,354,240 cpprest140_uwp_2_6.dll
    7.                 02/24/2016  05:27 PM           112,812 cpprest140_uwp_2_6.exp
    8.                 02/24/2016  05:27 PM           165,160 cpprest140_uwp_2_6.lib
    9.                 02/24/2016  05:28 PM        23,408,640 cpprest140_uwp_2_6.pdb
    10.                 02/24/2016  05:28 PM               968 cpprest140_uwp_2_6.pri
    11.             Microsoft.Xbox.Services.140.UWP.WinRT/
    12.                 02/24/2016  05:31 PM         8,305,664 Microsoft.Xbox.Services.dll
    13.                 02/24/2016  05:29 PM             1,018 Microsoft.Xbox.Services.exp
    14.                 02/24/2016  05:29 PM             1,800 Microsoft.Xbox.Services.lib
    15.                 02/24/2016  05:31 PM       162,082,816 Microsoft.Xbox.Services.pdb
    16.                 02/24/2016  05:31 PM               720 Microsoft.Xbox.Services.pri
    17.  
     
  25. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    This looks correct. You're only shipping as x64? I'll double check the prebuild event tomorrow morning - I pasted it from a slightly older Unity version since I had that installed.

    You don't really need to use "C# projects", they're only helpful to be able to change code without rebuilding from Unity and get accurate intellisense. Still, this sounds weird, I'll try to get to the bottom of why it tries to reference Assembly-CSharp-firstpass from the Unprocessed folder.
     
  26. JohnnyWasabi

    JohnnyWasabi

    Joined:
    Jul 16, 2012
    Posts:
    43
    Thanks. Yes, I'm only supporting x64.
     
  27. JohnnyWasabi

    JohnnyWasabi

    Joined:
    Jul 16, 2012
    Posts:
    43
    I was able to build the app (although I had to build Assembly-CSharp twice to get past the SerializationWeaver failure), but the app when launched fails. It gets an error about not being able to cast SceneStart to a Unity class and something about serialization not matching (it asks "did you #ifdef Unity_Editor in a serialized class?"). Then it just gets a ton of null errors. The splash screen never comes up.

    It does report this error when building Assembly-CSharp-firstpass:
    Code (csharp):
    1. Severity   Code   Description   Project   File   Line   Suppression State
    2. Error   CS0246   The type or namespace name 'UnityEngine' could not be found (are you missing a using directive or an assembly reference?)   Wasteland2DirectorsCut   F:\Projects\WL2\Builds\Test3\Wasteland2DirectorsCut\MainPage.xaml.cs   5   Active
     
    Last edited: Mar 2, 2016
  28. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    I suppose this doesn't happen without "C# projects option"? Did you by any chance add additional fields to any of your classes after building the project from Unity?
     
  29. JohnnyWasabi

    JohnnyWasabi

    Joined:
    Jul 16, 2012
    Posts:
    43
    Correct. Without C# projects, the game builds and plays just fine. I did not add any additional fields to any classes after building the project from Unity. The code has been unchanged for some time, other than a brief attempt to add an XboxLiveScript to test XboxLive connection, as per the instructions I was following. But at this point that code is not used (it's a Monobehavior that is not on any object). I built it again last night without C# projects just to make sure it still built and ran, and it did build and run fine.
     
  30. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    This error usually means a bug in our serialization pipeline - although I am not sure why it happens only when you use "C# Projects" option. At least you're not blocked from building your game.

    Is reporting a bug with a repro project an option for you?
     
  31. JohnnyWasabi

    JohnnyWasabi

    Joined:
    Jul 16, 2012
    Posts:
    43
    I found this in one of the game's MonoBehaviour classes:
    Code (CSharp):
    1. #if NETFX_CORE
    2.     FileStream fs = null;
    3. #endif
    Would that cause the mismatch? I think NETFX_CORE is not defined when compiling in Editor, but is when building the Visual Studio UWP solution.
     
  32. JohnnyWasabi

    JohnnyWasabi

    Joined:
    Jul 16, 2012
    Posts:
    43
    Unfortunately, while I can build the game, I can't publish it without XBoxLive support (because the Xbox version supports it and Microsoft policy requires parity on Windows 10 Store). For practical purposes, this issue is essentially blocking me from adding XBoxLive support.

    Submitting a repro project for the bug is problematic because the project is so huge. Pairing it down is not practical for me.
     
  33. JohnnyWasabi

    JohnnyWasabi

    Joined:
    Jul 16, 2012
    Posts:
    43
    I found another instance of different fields based on NETFX_CORE, but this time fields are removed from a MonoBehaviour:
    Code (CSharp):
    1.     // Thread vals
    2. #if !NETFX_CORE
    3.     private     Thread                  thread = null;
    4.     private bool threadStarted = false;
    5.     private bool stopThread = false;
    6. #endif
    7.  
     
  34. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    You don't need to use C# projects to use xbox live plugins. It only gives you intellisense, which makes it easier to use.

    You can write the code in a separate VS project while referencing the plugins to get intellisense for development and then copy the code over to Unity (or even compile it to a DLL and drop that to your unity project).

    Oh, and btw NETFX_CORE is defined when you build for Windows Store out of the editor. It's just not enabled when the scripts are built for the editor for running in playmode.
     
    JohnnyWasabi likes this.
  35. MattWhiting

    MattWhiting

    Joined:
    Jan 11, 2016
    Posts:
    79
    Has there been any update on this? It would be MUCH easier to port our code from XBoxOne to Windows UWP if such a plugin existed. If it was being worked on 2 years ago, did that ever happen?
     
  36. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    We decided to go the other way. We enabled consuming Windows Runtime APIs directly from C# on IL2CPP, so you can call into Xbox Live directly from your scripts without any plugins. This approach works both for UWP and Xbox One/ERA.
     
  37. MattWhiting

    MattWhiting

    Joined:
    Jan 11, 2016
    Posts:
    79
    Ok so how? For the Xbox One, I found the instructions for setting the Roslyn compiler... but where are the instructions for the UWP PC build?
     
  38. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
  39. MattWhiting

    MattWhiting

    Joined:
    Jan 11, 2016
    Posts:
    79
    That's somewhat helpful. I've followed those instructions (actually had already gotten that far, but at least it clarifies I'm following the right instructions).
    I have found https://github.com/Microsoft/xbox-live-api
    I downloaded that, and after some minor fixes, I was able to build Microsoft.Xbox.Services.140.UWP.WinRT.sln to generate Microsoft.Xbox.Services.winmd.
    This I have added into my plugins folder and configured it to be used for all build configurations (for now).

    This builds and runs. But I get an exception when I attempt to create my XboxLiveUser.

    Some digging around suggested this could be due to a poorly configured XboxServices.config, Package.appxmanifest, or pfx file. I have made every effort to ensure that these are correct.

    I also downloaded https://github.com/Microsoft/xbox-live-unity-plugin/releases and imported XboxLive.unitypackage. This allowed me to set up an example project and confirm that my various configurations are correct.

    Now if I disable the DLLs from that package and re-add my winmd, I get the exception when attempting to create my XboxLiveUser.

    Here's my script if that's at all useful:

    Code (CSharp):
    1. using System;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. #if ENABLE_WINMD_SUPPORT
    7. using Microsoft.Xbox.Services;
    8. using Microsoft.Xbox.Services.System;
    9. #endif
    10.  
    11. public class Test : MonoBehaviour
    12. {
    13. #if ENABLE_WINMD_SUPPORT
    14.     XboxLiveUser m_user = null;
    15.     XboxLiveContext m_context = null;
    16.     Windows.UI.Core.CoreDispatcher m_dispatcher = null;
    17. #endif
    18.  
    19.     // Use this for initialization
    20.     void Start ()
    21.     {
    22. #if ENABLE_WINMD_SUPPORT
    23.         Debug.LogError("23");
    24.         m_user = new XboxLiveUser();
    25.         Debug.LogError("25");
    26.         Windows.ApplicationModel.Core.CoreApplicationView mainView = Windows.ApplicationModel.Core.CoreApplication.MainView;
    27.         Debug.LogError("27");
    28.         Windows.UI.Core.CoreWindow cw = mainView.CoreWindow;
    29.         Debug.LogError("29");
    30.         m_dispatcher = cw.Dispatcher;
    31.         Debug.LogError("31");
    32.         SignIn();
    33.         Debug.LogError("33");
    34. #endif
    35.     }
    36.  
    37. #if ENABLE_WINMD_SUPPORT
    38.     private async void SignIn()
    39.     {
    40.         Debug.LogError("SignIn");
    41.         SignInResult silentSignInResult = await m_user.SignInSilentlyAsync(m_dispatcher);
    42.         bool signedIn = false;
    43.         switch (silentSignInResult.Status)
    44.         {
    45.             case SignInStatus.Success:
    46.         Debug.LogError("Success");
    47.                 signedIn = true;
    48.                 break;
    49.             case SignInStatus.UserInteractionRequired:
    50.         Debug.LogError("UserInteractionRequired");
    51.                 SignInResult loudSignInResult = await m_user.SignInAsync(m_dispatcher);
    52.                 switch (loudSignInResult.Status)
    53.                 {
    54.                     case SignInStatus.Success:
    55.         Debug.LogError("Success");
    56.                         signedIn = true;
    57.         //m_service.UpdateAchievementAsync(m_user.XboxUserId, "3", 100);
    58.                         break;
    59.                     case SignInStatus.UserCancel:
    60.         Debug.LogError("UserCancel");
    61.                         // TODO: retry sign in
    62.                         break;
    63.                     default:
    64.         Debug.LogError("default");
    65.                         break;
    66.                 }
    67.                 break;
    68.             case SignInStatus.UserCancel:
    69.         Debug.LogError("UserCancel");
    70.                 // TODO: retry or exit
    71.                 break;
    72.             default:
    73.         Debug.LogError("default");
    74.                 break;
    75.         }
    76.  
    77.         if( signedIn )
    78.         {
    79.             m_context = new XboxLiveContext(m_user);
    80.             Debug.LogError("User signed in: " + m_user.Gamertag);
    81.         }
    82.         else
    83.         {
    84.             Debug.LogError("No User");
    85.         }
    86.  
    87.     }
    88. #endif
    89. }
    90.  
     
  40. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    What exception did you get? Did you copy both winmd and dll files to your Unity project? Just winmd is not enough.
     
  41. MattWhiting

    MattWhiting

    Joined:
    Jan 11, 2016
    Posts:
    79
    Yes I also copied in the Microsoft.Xbox.Services.dll right next to the Microsoft.Xbox.Services.winmd

    The exception is:

    Exception: Exception of type 'System.Exception' was thrown.
    at Microsoft.Xbox.Services.System.XboxLiveUser..ctor () [0x00000] in <00000000000000000000000000000000>:0
    at Test.Start () [0x00000] in <00000000000000000000000000000000>:0
     
  42. MattWhiting

    MattWhiting

    Joined:
    Jan 11, 2016
    Posts:
    79
    inline Il2CppIActivationFactory* il2cpp_codegen_windows_runtime_get_activation_factory(const il2cpp::utils::StringView<Il2CppNativeChar>& runtimeClassName)
    {
    return il2cpp::vm::WindowsRuntime::GetActivationFactory(runtimeClassName);
    }
    with runtimeClassName = L"Microsoft.Xbox.Services.System.XboxLiveUser"

    il2cpp_hresult_t hr = os::WindowsRuntime::GetActivationFactory(className, &factory);
    returns 0x8007007e

    Presumably there's no XboxLiveUser in the class registry for my dll... ?
     
  43. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    That error code means "Module not found" (ERROR_MOD_NOT_FOUND). Which files did you copy into your project? The class registry is fine, otherwise you'd get "Class not registered".
     
  44. MattWhiting

    MattWhiting

    Joined:
    Jan 11, 2016
    Posts:
    79
    I just noticed this in the dll spam when launching the program
    Failed to load 'Microsoft.Xbox.Services.dll', expected x86 architecture, but was Unknown architecture. You must recompile your plugin for x86 architecture.
    same thing happens with x64.
     
  45. MattWhiting

    MattWhiting

    Joined:
    Jan 11, 2016
    Posts:
    79
    I don't get this. I've compiled Microsoft.Xbox.Services.140.UWP.WinRT.sln for each x86 and x64. I copied the matching DLLs into my Unity project as:
    "Assets\Plugins\x64\Microsoft.Xbox.Services.dll"
    and
    "Assets\Plugins\x86\Microsoft.Xbox.Services.dll"
    In Unity, I have them marked as x64 and x86 under Platform Settings->CPU

    The winmd file I copied to:
    "Assets\Plugins\Microsoft.Xbox.Services.winmd"
    The winmd is supposed to be platform agnostic if I understand it correctly, but I copied the x64 version of it if that matters at all.

    Scripting backend is IL2CPP

    I Build the project and then open the resulting sln file in VS2017.
    I set VS to x64
    I build it and launch the debugger... and it complains that my Microsoft.Xbox.Services.dll is the wrong architecture.
     
  46. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    That wrong architecture error message is a red herring. That's not the reason why this fails. Could we have a bug report on it (about the message, not the fact that it fails to load).

    I cloned the repository and built Microsoft.Xbox.Services.dll myself. Turns out, it depends on another DLL:

    upload_2018-9-7_12-30-19.png

    You need to copy that DLL into Unity project too. It gets built when you build Microsoft.Xbox.Services.140.UWP.WinRT.sln.
     
    MattWhiting likes this.
  47. MattWhiting

    MattWhiting

    Joined:
    Jan 11, 2016
    Posts:
    79
    Thanks! That was exactly it. Am I really the only person who has failed to realize there was a dependent DLL tucked away in another folder?
     
  48. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    Last time I checked (around the year ago) they were in the same folder. Perhaps they messed up their buildsystem :). I'd suggest filing an issue on github on that.
     
  49. RestlessCorp

    RestlessCorp

    Joined:
    Apr 20, 2019
    Posts:
    22
    I have trouble with integration of achievements, why here is no samples how to integrate Xbox live achievements with Unity C# ?
     
  50. RestlessCorp

    RestlessCorp

    Joined:
    Apr 20, 2019
    Posts:
    22


    Have you found a way to implement achievements?