none
Accessing Windows 10 functions from Unity IL2CPP project via a class library

    Question

  • I have been trying to create a UWP class library that gives me access to Windows 10s native features such as Windows.Security.Authentication.OnlineId. I would like to get a username and ID from the device for use in a Unity UWP IL2CPP project. I am currently able to do this with Unity's built in social class for ios and there is code which google has written that allows this to work seamlessly with the same class but for android's Google Play Games.

    I've downloaded a sample off github (https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/WebAccountManagement) which demonstrates how to call the relevant classes and functions in a UWP app and works well but the samples appear to be are accessing classes from the "Windows.Foundation.UniversalApiContract" class.

    I can't seem to find a way to add this to a basic UWP class library so I can call on the required classes such as Windows::Security::Credentials::WebAccountProvider.

    The best I've been able to do is create a basic function in the class library that returns a small hardcoded string just to test if the concept was remotely possible.
    :-

        extern "C" __declspec(dllexport) wchar_t* __stdcall GetMyString()    {    	wchar_t* myString = L"Guuuper";    	auto resultBufferLength = wcslen(myString) + 1;    	wchar_t* result = static_cast<wchar_t*>(CoTaskMemAlloc(resultBufferLength * sizeof(wchar_t)));    	wcscpy_s(result, resultBufferLength, myString);    	return result;        }



    My whole journey in attempting to do that can be found here:-
    http://forum.unity3d.com/threads/returning-c-string-to-il2cpp-windows-store-project.395284/

    I've been able to successfully call this code from within unity via a UWP build but my main question is how I would go about adding the appropriate references or how I would create this class library to access the WebAccountProvider class?

    I've asked the same question on StackOverflow and am even offering 50 bounty but haven't managed to get enough attention on the matter.

    Any help would be much appreciated

    Software Developer / 3D Modeler / Graphic Designer / Web Designer www.samsongabriels.co.uk Livin' 4 Christ!

    Friday, July 22, 2016 7:07 PM

All replies

  • Hi Nerosam,

    Based on your description, this issue would be related Unity, to help you resolve this issue, you could post this issue to the unity forum here which is related to the windows development.

    http://forum.unity3d.com/forums/windows-development.50/

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you.

    Microsoft does not control these sites and has not tested any software or information found on these sites;

    Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.

    There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, July 25, 2016 12:20 PM
    Moderator
  • Thanks for the reply Jack.

    I'm not sure if my question was clear. All I want to do is call on UWP functions from a C++ DLL file. I then need to be able to call on that C++ function from elsewhere (e.g Unity) but the main question is how do I start with doing that without creating a UWP App? All I need is a DLL file with a function created that calls on Windows::Security::Credentials::WebAccountProvider so I can get a username in the form of a string.

    Kind Regards,

    Sam


    Software Developer / 3D Modeler / Graphic Designer / Web Designer www.samsongabriels.co.uk Livin' 4 Christ!



    • Edited by Nerosam Monday, July 25, 2016 5:09 PM
    Monday, July 25, 2016 5:08 PM
  • Hi  Sam,

    Thanks for your friendly response.

    >>All I want to do is call on UWP functions from a C++ DLL file. I then need to be able to call on that C++ function from elsewhere (e.g Unity) but the main question is how do I start with doing that without creating a UWP App?

    >>I have been trying to create a UWP class library that gives me access to Windows 10s native features such as Windows.Security.Authentication.OnlineId.

    So it is the UWP class library, am I right?

    If so, I suggest you post this issue to the UWP developing forum, you know that the VS General forum is to discuss the VS IDE usage, if you post this developing issue to a more appropriate forum, I think you would get dedicated support.

    But if it is the general VC++ class library, maybe the VC++ language developing forum would be better.

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Tuesday, July 26, 2016 11:58 AM
    Moderator