C++RAW #include "UnityPrefix.h" #include "Runtime/Mono/MonoManager.h" #include "Runtime/Scripting/ScriptingUtility.h" #include "Runtime/Scripting/ScriptingExportUtility.h" #if UNITY_METRO #include "PlatformDependent/MetroPlayer/AppCallbacks.h" #endif using namespace Unity; using namespace std; CSRAW using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using UnityEngineInternal; namespace UnityEngine.WSA { CONDITIONAL UNITY_METRO_API public delegate void AppCallbackItem(); CONDITIONAL UNITY_METRO_API public delegate void WindowSizeChanged(int width, int height); CONDITIONAL UNITY_METRO_API ENUM WindowActivationState CodeActivated = 0, Deactivated = 1, PointerActivated = 2 END CONDITIONAL UNITY_METRO_API public delegate void WindowActivated(WindowActivationState state); CONDITIONAL UNITY_METRO_API CLASS Application public static event WindowSizeChanged windowSizeChanged; public static event WindowActivated windowActivated; CSRAW public static string arguments { get { return GetAppArguments(); } } CUSTOM private static string GetAppArguments() { #if UNITY_METRO std::string args = ConvertStringToUtf8(UnityPlayer::AppCallbacks::Instance->GetAppArguments()); return scripting_string_new(args); #else return scripting_string_new(""); #endif } CSRAW internal static void InvokeWindowSizeChangedEvent(int width, int height) { if (windowSizeChanged != null) windowSizeChanged.Invoke(width, height); } CSRAW internal static void InvokeWindowActivatedEvent(WindowActivationState state) { if (windowActivated != null) windowActivated.Invoke(state); } CSRAW public static void InvokeOnAppThread(AppCallbackItem item, bool waitUntilDone) { #if UNITY_EDITOR item(); #else InternalInvokeOnAppThread(item, waitUntilDone); #endif } CSRAW public static void InvokeOnUIThread(AppCallbackItem item, bool waitUntilDone) { #if UNITY_EDITOR item(); #else InternalInvokeOnUIThread(item, waitUntilDone); #endif } CUSTOM internal static void InternalInvokeOnAppThread(AppCallbackItem item, bool waitUntilDone) { #if UNITY_METRO UnityPlayer::AppCallbacks::Instance->InvokeOnAppThread(ref new UnityPlayer::AppCallbackItem( GetWinRTTypeInformation()->CastScriptingObjectToAppCallbackItemStub(item)), waitUntilDone); #endif } CUSTOM internal static void InternalInvokeOnUIThread(AppCallbackItem item, bool waitUntilDone) { #if UNITY_METRO UnityPlayer::AppCallbacks::Instance->InvokeOnUIThread(ref new UnityPlayer::AppCallbackItem( GetWinRTTypeInformation()->CastScriptingObjectToAppCallbackItemStub(item)), waitUntilDone); #endif } CUSTOM public static bool RunningOnAppThread() { #if UNITY_METRO return UnityPlayer::AppCallbacks::Instance->RunningOnAppThread(); #else return true; #endif } CUSTOM public static bool RunningOnUIThread() { #if UNITY_METRO return UnityPlayer::AppCallbacks::Instance->RunningOnUIThread(); #else return true; #endif } CSRAW END CSRAW }