diff --git a/com.microsoft.mixedreality.webview.unity/.npmignore b/com.microsoft.mixedreality.webview.unity/.npmignore new file mode 100644 index 0000000..ed9cb29 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/.npmignore @@ -0,0 +1,5 @@ +package-lock.json.meta +Runtime\Plugins\android.meta +Runtime\Plugins\android\MicrosoftWebViewUnityPlugin.aar.meta +Runtime\Platform\AndroidWebView.cs +Runtime\Platform\AndroidWebView.cs.meta diff --git a/com.microsoft.mixedreality.webview.unity/CHANGELOG.md b/com.microsoft.mixedreality.webview.unity/CHANGELOG.md new file mode 100644 index 0000000..bfecb72 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/CHANGELOG.md @@ -0,0 +1,26 @@ +# Changelog + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). + +## [0.22.7-pre.1] - 2024-07-02 + +## [0.22.6] - 2024-06-06 [DEPRECATED] + +### Fix + +- Minor issue related to error hanlding for missing WebView2 runtime. + +## [0.22.5] - 2024-05-29 [DEPRECATED] + +### Added + +- Added support for SSO +- Added new permission-related APIs: + - `GetNonDefaultPermissionSettings()` + - `SetPermissionState()` + - `PermissionRequested` event +- Added new events: + - `NavigationStarting` + - `NavigationCompleted` + - `DocumentTitleChanged` +- Added improved error handling for missing WebView2 runtime. diff --git a/com.microsoft.mixedreality.webview.unity/CHANGELOG.md.meta b/com.microsoft.mixedreality.webview.unity/CHANGELOG.md.meta new file mode 100644 index 0000000..d6bdc44 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/CHANGELOG.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 38B583B9B8ED4C2785A706FEAA12E08C +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime.meta b/com.microsoft.mixedreality.webview.unity/Runtime.meta new file mode 100644 index 0000000..65ff76e --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f8b41e51988373a4da1960ca21133e0f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Editor.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Editor.meta new file mode 100644 index 0000000..996307a --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c1a50beb5edd1e943b47b7e3872481e2 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Editor/EditorWebView.cs b/com.microsoft.mixedreality.webview.unity/Runtime/Editor/EditorWebView.cs new file mode 100644 index 0000000..a23fcca --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Editor/EditorWebView.cs @@ -0,0 +1,135 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// + +namespace Microsoft.MixedReality.WebView +{ +#if UNITY_EDITOR + using System; + using System.Collections.Generic; + using UnityEditor; + using UnityEngine; + + public class EditorWebView : EditorWindow + { + IWebView webView = null; + int windowWidth = 800; + int windowHeight = 640; + int scrollSpeed = -12; + readonly Queue> webViewReadyCallbacks = new(); + + void Awake() + { + wantsMouseMove = true; + titleContent = new GUIContent("Test WebView"); + minSize = new Vector2(windowWidth, windowHeight); + } + + // TODO (rogerdis): Consolidate this logic with WebView.cs + /// + /// Takes a callback that is invoked either immediately if the IWebView instance has already been created, or once the IWebView instance is created. + /// + /// The callback, which can be a lambda or any function taking an IWebView instance as the only argument. + public void GetWebViewWhenReady(Action callback) + { + if (this.webView is null) + { + webViewReadyCallbacks.Enqueue(callback); + } + else + { + callback(this.webView); + } + } + + void Update() + { + if (webView == null) + { + webView = WebViewSystem.CreateWebView(null, windowWidth, windowHeight, "Microsoft.MixedReality.WebView.EditorWebView:UnityGUIViewWndClass"); + webView.OnceCreated.ContinueWith((task) => + { + while (webViewReadyCallbacks.Count > 0) + { + webViewReadyCallbacks.Dequeue()(webView); + } + }); + } + else + { + Repaint(); + } + } + + void OnDestroy() + { + webView?.Dispose(); + } + + void OnGUI() + { + if (webView == null) + { + return; + } + + var rootVisualWidth = (int) this.rootVisualElement.layout.width; + var rootVisualHeight = (int) this.rootVisualElement.layout.height; + if (rootVisualWidth != windowWidth || rootVisualHeight != windowHeight) + { + windowWidth = rootVisualWidth; + windowHeight = rootVisualHeight; + webView.Resize(windowWidth, windowHeight); + } + + if (webView.Texture != null) + { + Graphics.DrawTexture(new Rect(0, 0, windowWidth, windowHeight), webView.Texture); + } + + var currentEvent = Event.current; + if (currentEvent.isMouse || currentEvent.isScrollWheel) + { + WebViewMouseEventData wmed = new WebViewMouseEventData + { + X = (int)currentEvent.mousePosition.x, + Y = (int)currentEvent.mousePosition.y, + TertiaryAxisDeviceType = WebViewMouseEventData.TertiaryAxisDevice.PointingDevice, + WheelY = (currentEvent.delta.y * scrollSpeed), + Button = WebViewMouseEventData.MouseButton.ButtonNone, + Device = WebViewMouseEventData.DeviceType.Mouse, + }; + + switch (currentEvent.type) + { + case EventType.MouseDown: + wmed.Type = WebViewMouseEventData.EventType.MouseDown; + break; + case EventType.MouseUp: + wmed.Type = WebViewMouseEventData.EventType.MouseUp; + break; + case EventType.MouseMove: + wmed.Type = WebViewMouseEventData.EventType.MouseMove; + break; + case EventType.ScrollWheel: + wmed.Type = WebViewMouseEventData.EventType.MouseWheel; + break; + } + + if (currentEvent.button == 0) + { + wmed.Button = WebViewMouseEventData.MouseButton.ButtonLeft; + } + else if (currentEvent.button == 1) + { + wmed.Button = WebViewMouseEventData.MouseButton.ButtonRight; + } + + (webView as IWithMouseEvents)?.MouseEvent(wmed); + } + } + } +#else + public sealed class EditorWebView {} +#endif +} \ No newline at end of file diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Editor/EditorWebView.cs.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Editor/EditorWebView.cs.meta new file mode 100644 index 0000000..efc1953 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Editor/EditorWebView.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e9bd73ca44a9f424fa5ca0b8a361d4ee +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/IWebView.cs b/com.microsoft.mixedreality.webview.unity/Runtime/IWebView.cs new file mode 100644 index 0000000..853b278 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/IWebView.cs @@ -0,0 +1,161 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// + +namespace Microsoft.MixedReality.WebView +{ + using System; + using System.Net; + using System.Threading.Tasks; + using UnityEngine; + + public delegate void WebView_OnNavigated(string path); + + public delegate void WebView_OnCanGoForwardUpdated(bool value); + + public delegate void WebView_OnCanGoBackUpdated(bool value); + + public delegate void WebView_OnNewWindowRequested(string uri); + + public delegate void WebView_OnCloseRequested(); + + public delegate void WebView_OnInputChanged(bool requested); + + public delegate void WebView_OnPostMessage(string message); + + public delegate void WebView_OnNavigationBlocked(string uri); + + public delegate void WebView_OnNavigationStarting(Int64 navigationId, string uri); + + public delegate void WebView_OnNavigationCompleted(Int64 navigationId, bool succeeded); + + public delegate void WebView_OnDocumentTitleChanged(string newTitle); + + public delegate void WebView_OnPermissionSettingFound(string origin, WebViewPermissionKind kind, WebViewPermissionState state, bool enumerationComplete); + + public delegate void WebView_OnPermissionRequested(string origin, bool userInitiated, WebViewPermissionKind kind, ref WebViewPermissionState state, ref bool handled); + + public enum WebViewRefreshRate + { + None = 0, + Slow, + Fast + } + + public enum WebViewPermissionKind + { + Unknown = 0, + Microphone = 1, + Camera = 2, + Geolocation = 3, + Notifications = 4, + OtherSensors = 5, + ClipboardRead = 6, + MultipleAutomaticDownloads = 7, + FileReadWrite = 8, + Autoplay = 9, + LocalFonts = 10, + MidiSystemExclusiveMessages = 11, + WindowManagement = 12 + } + + public enum WebViewPermissionState + { + Default = 0, + Allow = 1, + Deny = 2 + } + + public interface IWebView + { + event WebView_OnNavigated Navigated; + + event WebView_OnNewWindowRequested NewWindowRequested; + + event WebView_OnCloseRequested WindowCloseRequested; + + GameObject GameObject { get; } + + Texture2D Texture { get; } + + int Width { get; set; } + + int Height { get; set; } + + Uri Page { get; } + + Task OnceCreated { get; } + + void Resize(int width, int height); + + void Load(Uri url); + + void Dispose(); + } + + public interface IWithInputEvents : IWebView + { + } + + public interface IWithMouseEvents : IWithInputEvents + { + void MouseEvent(WebViewMouseEventData mouseEvent); + } + + public interface IWithPostMessage : IWebView + { + event WebView_OnPostMessage MessageReceived; + + void PostMessage(string message, bool isJSON = false); + } + + public interface IWithBrowserHistory : IWebView + { + event WebView_OnCanGoForwardUpdated CanGoForwardUpdated; + + event WebView_OnCanGoBackUpdated CanGoBackUpdated; + + void GoBack(); + + void GoForward(); + } + + public interface IWithHTMLInjection : IWebView + { + void LoadHTMLContent(string htmlContent); + } + + public interface IWithVirtualHost: IWebView + { + void SetVirtualHostMapping(string hostName, string folderPath); + } + + public interface IWithSystemFocusCapture: IWebView + { + void ReleaseFocus(); + } + + internal interface IWithContentScale : IWebView + { + void SetContentScale(double scale); + } + + public interface IWithNavigationFiltering : IWebView + { + event WebView_OnNavigationBlocked NavigationBlocked; + } + + public interface IWithExtendedEvents : IWebView + { + event WebView_OnNavigationStarting NavigationStarting; + event WebView_OnNavigationCompleted NavigationCompleted; + event WebView_OnDocumentTitleChanged DocumentTitleChanged; + } + + public interface IWithPermissionSettings : IWebView + { + event WebView_OnPermissionRequested PermissionRequested; + void GetNonDefaultPermissionSettings(WebView_OnPermissionSettingFound settingFoundCallback); + void SetPermissionState(string origin, WebViewPermissionKind kind, WebViewPermissionState state); + } +} \ No newline at end of file diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/IWebView.cs.meta b/com.microsoft.mixedreality.webview.unity/Runtime/IWebView.cs.meta new file mode 100644 index 0000000..3236ceb --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/IWebView.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3aad5d98c1b8c914b9a146d4415409f9 +timeCreated: 1440212729 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Microsoft.MixedReality.Webview.asmdef b/com.microsoft.mixedreality.webview.unity/Runtime/Microsoft.MixedReality.Webview.asmdef new file mode 100644 index 0000000..42e8578 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Microsoft.MixedReality.Webview.asmdef @@ -0,0 +1,15 @@ +{ + "name": "Microsoft.MixedReality.WebView", + "rootNamespace": "Microsoft.MixedReality.WebView", + "references": [ + "Unity.InputSystem" + ], + "includePlatforms": [], + "excludePlatforms": [], + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Microsoft.MixedReality.Webview.asmdef.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Microsoft.MixedReality.Webview.asmdef.meta new file mode 100644 index 0000000..37b27f8 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Microsoft.MixedReality.Webview.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 585a6f6d63508094cbb30e4a714b8d25 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/OnChangedCall.cs b/com.microsoft.mixedreality.webview.unity/Runtime/OnChangedCall.cs new file mode 100644 index 0000000..f68c152 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/OnChangedCall.cs @@ -0,0 +1,82 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// + +namespace Microsoft.MixedReality.WebView +{ + using System.Linq; + using UnityEngine; + using UnityEditor; + using System.Reflection; + + internal class OnChangedCallAttribute : PropertyAttribute + { + public readonly string methodName; + public OnChangedCallAttribute(string methodNameNoArguments) + { + methodName = methodNameNoArguments; + } + } + + internal class OnRangeChangedCallAttribute : OnChangedCallAttribute + { + public readonly float min; + public readonly float max; + + public OnRangeChangedCallAttribute(float min, float max, string methodNameNoArguments) : base(methodNameNoArguments) + { + this.min = min; + this.max = max; + } + } + +#if UNITY_EDITOR + internal abstract class AbstractOnChangedCallAttributePropertyDrawer : PropertyDrawer + { + protected abstract void RenderField(Rect position, SerializedProperty property, GUIContent label); + + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + EditorGUI.BeginChangeCheck(); + RenderField(position, property, label); + if (EditorGUI.EndChangeCheck()) + { + // Update the serialized field + property.serializedObject.ApplyModifiedProperties(); + + var targetMethodName = (attribute as OnChangedCallAttribute).methodName; + var targetObject = property.serializedObject.targetObject; + MethodInfo method = targetObject.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Where((m) => m.Name == targetMethodName).First(); + if (method != null && method.GetParameters().Count() == 0) + { + method.Invoke(targetObject, null); + } + } + } + } + + [CustomPropertyDrawer(typeof(OnChangedCallAttribute))] + internal class OnChangedCallAttributePropertyDrawer : AbstractOnChangedCallAttributePropertyDrawer + { + protected override void RenderField(Rect position, SerializedProperty property, GUIContent label) + { + EditorGUI.PropertyField(position, property, label); + } + } + + [CustomPropertyDrawer(typeof(OnRangeChangedCallAttribute))] + internal class OnRangeChangedCallAttributePropertyDrawer : AbstractOnChangedCallAttributePropertyDrawer + { + protected override void RenderField(Rect position, SerializedProperty property, GUIContent label) + { + var attribute = this.attribute as OnRangeChangedCallAttribute; + if (property.propertyType == SerializedPropertyType.Float) + EditorGUI.Slider(position, property, attribute.min, attribute.max, label); + else if (property.propertyType == SerializedPropertyType.Integer) + EditorGUI.IntSlider(position, property, (int)attribute.min, (int)attribute.max, label); + else + EditorGUI.LabelField(position, label.text, "Use OnRangeChangedCall with float or int."); + } + } +#endif +} \ No newline at end of file diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/OnChangedCall.cs.meta b/com.microsoft.mixedreality.webview.unity/Runtime/OnChangedCall.cs.meta new file mode 100644 index 0000000..5ef7bad --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/OnChangedCall.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ff1990cdfead37e43af62bdf8741986d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Platform.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Platform.meta new file mode 100644 index 0000000..1e4e2ce --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Platform.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c09ba26e5a08f2d4284f5d68132d7899 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Platform/BaseWebView.cs b/com.microsoft.mixedreality.webview.unity/Runtime/Platform/BaseWebView.cs new file mode 100644 index 0000000..0c7355c --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Platform/BaseWebView.cs @@ -0,0 +1,309 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// + +namespace Microsoft.MixedReality.WebView +{ + using System; + using System.Threading; + using System.Threading.Tasks; + using AOT; + using UnityEngine; + using System.Runtime.InteropServices; + + internal abstract class BaseWebView : IWebView, IWithPostMessage, IWithMouseEvents, IWithBrowserHistory, IWithHTMLInjection, IWithContentScale, IWithNavigationFiltering + { + + #region Events + public event WebView_OnNavigated Navigated; + public event WebView_OnPostMessage MessageReceived; + public event WebView_OnCanGoForwardUpdated CanGoForwardUpdated; + public event WebView_OnCanGoBackUpdated CanGoBackUpdated; + public event WebView_OnNewWindowRequested NewWindowRequested; + public event WebView_OnCloseRequested WindowCloseRequested; + public event WebView_OnNavigationBlocked NavigationBlocked; + + #endregion + + private readonly TaskCompletionSource whenReadyTCS = new TaskCompletionSource(); + private readonly WeakReference gameObject; + private int activeResizeRequestCount = 0; + private Texture2D targetTexture; + public IntPtr InstanceId { get; private set; } + private int width; + private int height; + + public int Width + { + get => width; + set { Resize(value, Height); } + } + + public int Height + { + get => height; + set { Resize(Width, value); } + } + + // Unity API's (e.g. UnityEngine.Behaviour::set_enabled) must be called from Unity's main thread (i.e. game thread or app thread). + // However, WebView2 callbacks are executed on WinRT's main thread. + // Use SynchronizationContext to ensure any Unity API calls are made from Unity's main thread and at the plugin layer so that + // consumers of the plugin do not run into wrong thread type violations + protected SynchronizationContext UnityGameThreadContext; + private TaskScheduler UnityGameThreadScheduler; + + public GameObject GameObject => (GameObject)gameObject.Target; + public Texture2D Texture => targetTexture; + + public BaseWebView(GameObject gameObject, int width, int height, string parentHWNDHint = null) + { +#if UNITY_WSA && !UNITY_EDITOR + // WebViews created in the editor don't need this check as the editor is a Win32 app. + // The UNITY_WSA refers to the currently set target platform, so we also need to check if !UNITY_EDITOR. + Debug.Assert(WebViewSystem.AppThread == System.Threading.Thread.CurrentThread, "WebView was not created on the game thread"); +#endif + UnityGameThreadContext = SynchronizationContext.Current; + UnityGameThreadScheduler = TaskScheduler.FromCurrentSynchronizationContext(); + + this.gameObject = new WeakReference(gameObject); + this.width = width; + this.height = height; + +#if UNITY_WSA + // We need to create the WebView on the main thread. + // All other WebViewNative functions are thread-safe. + UnityEngine.WSA.Application.InvokeOnUIThread(() => { +#endif + int errorCode = 0; + InstanceId = WebViewNative.InitializeWebView(width, height, parentHWNDHint, ref errorCode); + if (errorCode != 0) + { + Debug.LogError($"Failed to create native WebView control. Exception code: {errorCode}"); + var creationException = Marshal.GetExceptionForHR(errorCode); + + UnityGameThreadContext.Post(_ => + { + this.whenReadyTCS.SetException(creationException); + }, null); + + return; + } + + WebViewNative.SetUrlChangedCallback(InstanceId, OnUrlChangedCallback); + WebViewNative.SetCanGoBackUpdatedCallback(InstanceId, OnGoBackStatusUpdated); + WebViewNative.SetCanGoForwardUpdatedCallback(InstanceId, OnGoForwardUpdated); + WebViewNative.SetPostMessageCallback(InstanceId, OnPostMessageCallback); + WebViewNative.SetReadyCallback(InstanceId, OnReadyCallback); + WebViewNative.SetTextureAvailableCallback(InstanceId, OnTextureAvailable); + WebViewNative.SetNewWindowRequestedCallback(InstanceId, OnNewWindowRequested); + WebViewNative.SetWindowCloseRequestedCallback(InstanceId, OnWindowCloseRequested); + WebViewNative.SetNavigationBlockedCallback(InstanceId, OnNavigationBlocked); +#if UNITY_WSA + }, true); +#endif + } + + + public Uri Page { get; private set; } + + public void Load(Uri url) + { + Page = url; + WebViewNative.SetWebViewUrl(InstanceId, url.AbsoluteUri); + } + + public void MouseEvent(WebViewMouseEventData mouseEvent) + { + WebViewNative.HandlePointerInput(InstanceId, mouseEvent.X, mouseEvent.Y, (int)mouseEvent.Device, (int)mouseEvent.Type, (int)mouseEvent.Button, (int)mouseEvent.WheelY); + } + + public void Resize(int width, int height) + { + // Run on the same thread as SetTargetTexture so we can properly synchronize. + OnceCreated.ContinueWith(_ => + { + targetTexture = null; + this.width = width; + this.height = height; + activeResizeRequestCount++; + WebViewNative.SetWebViewSize(InstanceId, width, height); + }, UnityGameThreadScheduler); + } + + private void SetTargetTexture(IntPtr externalTexturePtr) + { + // We need this to be the case so that: + // (1) We can access Unity GameObject methods + // (2) We properly synchronize against resize requests. + Debug.Assert(SynchronizationContext.Current == UnityGameThreadContext); + + // Consume resize request. + if (activeResizeRequestCount >= 1) + { + activeResizeRequestCount--; + } + + // Check if we're already asking for more resizes that will invalidate the target texture. + if (activeResizeRequestCount > 0) + { + return; + } + + targetTexture = Texture2D.CreateExternalTexture(width, height, TextureFormat.RGBA32, false, true, externalTexturePtr); + // Set point filtering just so we can see the pixels clearly + targetTexture.filterMode = FilterMode.Point; + targetTexture.wrapMode = TextureWrapMode.Clamp; + + if (this.gameObject.Target != null) + { + var webViewRenderer = this.GameObject.GetComponent(); + webViewRenderer.material.mainTexture = targetTexture; + } + } + + public void PostMessage(string message, bool isJSON = false) + { + WebViewNative.PostWebMessage(InstanceId, message, isJSON); + } + + public void LoadHTMLContent(string htmlContent) + { + WebViewNative.LoadHTMLContent(InstanceId, htmlContent); + } + + public void GoBack() + { + WebViewNative.GoBackOnWebView(InstanceId); + } + + public void GoForward() + { + WebViewNative.GoForwardOnWebView(InstanceId); + } + + public void Dispose() + { + WebViewNative.DestroyWebView(InstanceId); + WebViewSystem.ViewDestroyed(InstanceId); + } + + #region Callbacks + + [MonoPInvokeCallback(typeof(WebViewNative.NewWindowRequestedDelegate))] + private static void OnNewWindowRequested(IntPtr instanceId, string uri) + { + BaseWebView webView = WebViewSystem.FindWebView(instanceId) as BaseWebView; + if (webView != null) + { + webView.UnityGameThreadContext.Post(_ => webView.NewWindowRequested?.Invoke(uri), null); + } + } + + [MonoPInvokeCallback(typeof(WebViewNative.WindowCloseRequestedDelegate))] + private static void OnWindowCloseRequested(IntPtr instanceId) + { + BaseWebView webView = WebViewSystem.FindWebView(instanceId) as BaseWebView; + if (webView != null) + { + webView.UnityGameThreadContext.Post(_ => webView.WindowCloseRequested?.Invoke(), null); + } + } + + [MonoPInvokeCallback(typeof(WebViewNative.OnReadyDelegate))] + private static void OnReadyCallback(IntPtr instanceId) + { + BaseWebView webView = WebViewSystem.FindWebView(instanceId) as BaseWebView; + if (webView != null) + { + webView.UnityGameThreadContext.Post(_ => + { + webView.whenReadyTCS.SetResult(true); + }, null); + } + } + + [MonoPInvokeCallback(typeof(WebViewNative.TextureAvailableDelegate))] + private static void OnTextureAvailable(IntPtr instanceId, IntPtr texturePtr) + { + BaseWebView webView = WebViewSystem.FindWebView(instanceId) as BaseWebView; + if (webView != null) + { + webView.UnityGameThreadContext.Post(_ => + { + webView.SetTargetTexture(texturePtr); + }, null); + } + } + + [MonoPInvokeCallback(typeof(WebViewNative.PostMessageToUnityDelegate))] + private static void OnPostMessageCallback(IntPtr instanceId, string message) + { + BaseWebView webView = WebViewSystem.FindWebView(instanceId) as BaseWebView; + if (webView != null) + { + webView.UnityGameThreadContext.Post(_ => webView.MessageReceived?.Invoke(message), null); + } + } + + [MonoPInvokeCallback(typeof(WebViewNative.UrlChangedDelegate))] + private static void OnUrlChangedCallback(IntPtr instanceId, string url) + { + BaseWebView webView = WebViewSystem.FindWebView(instanceId) as BaseWebView; + if (webView != null) + { + webView.UnityGameThreadContext.Post(_ => + { + webView.Page = new Uri(url); + webView.Navigated?.Invoke(url); + }, null); + } + } + + [MonoPInvokeCallback(typeof(WebViewNative.NavigationBlockedDelegate))] + private static void OnNavigationBlocked(IntPtr instanceId, string blockedUri) + { + BaseWebView webView = WebViewSystem.FindWebView(instanceId) as BaseWebView; + webView?.UnityGameThreadContext.Post(_ => webView.NavigationBlocked?.Invoke(blockedUri), null); + } + + public bool CanGoBack { get; private set; } = false; + public bool CanGoForward { get; private set; } = false; + + [MonoPInvokeCallback(typeof(WebViewNative.NavigationButtonStatusUpdatedDelegate))] + private static void OnGoBackStatusUpdated(IntPtr instanceId, bool value) + { + BaseWebView webView = WebViewSystem.FindWebView(instanceId) as BaseWebView; + if (webView != null) + { + webView.UnityGameThreadContext.Post(_ => + { + webView.CanGoBack = value; + webView.CanGoBackUpdated?.Invoke(webView.CanGoBack); + }, null); + } + } + + [MonoPInvokeCallback(typeof(WebViewNative.NavigationButtonStatusUpdatedDelegate))] + private static void OnGoForwardUpdated(IntPtr instanceId, bool value) + { + BaseWebView webView = WebViewSystem.FindWebView(instanceId) as BaseWebView; + if (webView != null) + { + webView.UnityGameThreadContext.Post(_ => + { + webView.CanGoForward = value; + webView.CanGoForwardUpdated?.Invoke(webView.CanGoForward); + }, null); + } + } + #endregion + + public Task OnceCreated => whenReadyTCS.Task; + + public void SetContentScale(double scale) + { + WebViewNative.SetWebViewContentScale(InstanceId, scale); + } + } +} + diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Platform/BaseWebView.cs.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Platform/BaseWebView.cs.meta new file mode 100644 index 0000000..eb2babd --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Platform/BaseWebView.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 437d9c983ff103541a84f6f05cd5edae +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Platform/WebViewNative.cs b/com.microsoft.mixedreality.webview.unity/Runtime/Platform/WebViewNative.cs new file mode 100644 index 0000000..595f97f --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Platform/WebViewNative.cs @@ -0,0 +1,161 @@ +using System; +using System.Runtime.InteropServices; + +namespace Microsoft.MixedReality.WebView +{ + using WebViewInstancePtr = System.IntPtr; + using WebViewTexturePtr = System.IntPtr; + using ComNativePointer = System.IntPtr; + using PermissionStatePtr = System.IntPtr; + + internal static class WebViewNative + { + private const string DLL_NAME = "MicrosoftWebViewUnityPlugin"; + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct WebViewWindowFeatures + { + public bool HasSize; + public uint Height; + public uint Width; + }; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate void TextureAvailableDelegate([In] WebViewInstancePtr instanceId, [In]WebViewTexturePtr texturePtr); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate void UrlChangedDelegate([In] WebViewInstancePtr instanceId, [In][MarshalAs(UnmanagedType.LPWStr)] string url); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate void PostMessageToUnityDelegate([In] WebViewInstancePtr instanceId, [In][MarshalAs(UnmanagedType.LPWStr)] string message); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate void NavigationButtonStatusUpdatedDelegate([In] WebViewInstancePtr instanceId, [In] bool enabled); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate void WindowCloseRequestedDelegate([In] WebViewInstancePtr instanceId); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate void NewWindowRequestedDelegate([In] WebViewInstancePtr instanceId, [In][MarshalAs(UnmanagedType.LPWStr)] string uri); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate void OnReadyDelegate([In] WebViewInstancePtr instanceId); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate void NavigationBlockedDelegate([In] WebViewInstancePtr instanceId, [In][MarshalAs(UnmanagedType.LPWStr)] string uri); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate void NavigationStartingDelegate([In] WebViewInstancePtr instanceId, [In] Int64 navigationId, [In][MarshalAs(UnmanagedType.LPWStr)] string uri); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate void NavigationCompletedDelegate([In] WebViewInstancePtr instanceId, [In] Int64 navigationId, [In] bool succeeded); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate void DocumentTitleChanged([In] WebViewInstancePtr instanceId, [In][MarshalAs(UnmanagedType.LPWStr)] string newTitle); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate void NonDefaultPermissionSettingEnumDelegate([In] WebViewInstancePtr instanceId, [In][MarshalAs(UnmanagedType.LPWStr)] string origin, [In] int kind, [In] int state, [In] bool enumerationComplete); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate bool PermissionRequestedDelegate([In] WebViewInstancePtr instanceId, [In][MarshalAs(UnmanagedType.LPWStr)] string origin, [In] bool userInitiated, [In] int kind, [In] PermissionStatePtr state); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void ActivateKeyboard(); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void DeactivateKeyboard(); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void SetWebViewUrl(WebViewInstancePtr instanceId, string url); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void GoBackOnWebView(WebViewInstancePtr instanceId); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void GoForwardOnWebView(WebViewInstancePtr instanceId); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern WebViewInstancePtr InitializeWebView(int w, int h, string parentHWNDHint, ref int errorCode); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern WebViewTexturePtr GetOutputTexture(WebViewInstancePtr instanceId); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void DestroyWebView(WebViewInstancePtr instanceId); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void SetWebViewSize(WebViewInstancePtr instanceId, int w, int h); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void SetWebViewContentScale(WebViewInstancePtr instanceId, double scale); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern IntPtr GetRenderEventFunc(); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void SetTextureAvailableCallback(WebViewInstancePtr instanceId, TextureAvailableDelegate callback); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void SetUrlChangedCallback(WebViewInstancePtr instanceId, UrlChangedDelegate callback); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void SetCanGoBackUpdatedCallback(WebViewInstancePtr instanceId, NavigationButtonStatusUpdatedDelegate callback); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void SetCanGoForwardUpdatedCallback(WebViewInstancePtr instanceId, NavigationButtonStatusUpdatedDelegate callback); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void SetNewWindowRequestedCallback(WebViewInstancePtr instanceId, NewWindowRequestedDelegate callback); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void SetWindowCloseRequestedCallback(WebViewInstancePtr instanceId, WindowCloseRequestedDelegate callback); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void SetReadyCallback(WebViewInstancePtr instanceId, OnReadyDelegate callback); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void SetNavigationBlockedCallback(WebViewInstancePtr instanceId, NavigationBlockedDelegate callback); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void SetNavigationStartingCallback(WebViewInstancePtr instanceId, NavigationStartingDelegate callback); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void SetNavigationCompletedCallback(WebViewInstancePtr instanceId, NavigationCompletedDelegate callback); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void SetDocumentTitleChangedCallback(WebViewInstancePtr instanceId, DocumentTitleChanged callback); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void InvokeScript(WebViewInstancePtr instanceId, string script); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void HandlePointerInput(WebViewInstancePtr instanceId, int x, int y, int device, int pointerEvent, int pointerButton, int mouseWheel); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void SetPostMessageCallback(WebViewInstancePtr instanceId, PostMessageToUnityDelegate callback); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void PostWebMessage(WebViewInstancePtr instanceId, string url, bool isJSON); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void LoadHTMLContent(WebViewInstancePtr instanceId, string htmlContent); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void SetVirtualHostMapping(WebViewInstancePtr instanceId, string hostName, string folderPath); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void ReleaseFocus(WebViewInstancePtr instanceId); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void GetNonDefaultPermissionSettings(WebViewInstancePtr instanceId, NonDefaultPermissionSettingEnumDelegate settingFoundCallback); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void SetPermissionState(WebViewInstancePtr instanceId, string origin, int kind, int state); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern void SetPermissionRequestedCallback(WebViewInstancePtr instanceId, PermissionRequestedDelegate callback); + + [DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)] + public static extern ComNativePointer GetNativePointer(WebViewInstancePtr instanceId); + } +} \ No newline at end of file diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Platform/WebViewNative.cs.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Platform/WebViewNative.cs.meta new file mode 100644 index 0000000..d1806f9 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Platform/WebViewNative.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 02199c90f218b174a83a4a6ec1288135 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Platform/WindowsWebView.cs b/com.microsoft.mixedreality.webview.unity/Runtime/Platform/WindowsWebView.cs new file mode 100644 index 0000000..3ab8b5c --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Platform/WindowsWebView.cs @@ -0,0 +1,113 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// + +namespace Microsoft.MixedReality.WebView +{ + using System; + using UnityEngine; + using AOT; + using System.Runtime.InteropServices; + + internal class WindowsWebView : BaseWebView, IWithVirtualHost, IWithSystemFocusCapture, IWithExtendedEvents, IWithPermissionSettings + { + private event WebView_OnPermissionSettingFound permissionSettingFound; + public event WebView_OnNavigationStarting NavigationStarting; + public event WebView_OnNavigationCompleted NavigationCompleted; + public event WebView_OnDocumentTitleChanged DocumentTitleChanged; + public event WebView_OnPermissionRequested PermissionRequested; + + public WindowsWebView(GameObject gameObject, int width, int height, string parentHWNDHint) + : base(gameObject, width, height, parentHWNDHint) + { + WebViewNative.SetNavigationStartingCallback(InstanceId, OnNavigationStarting); + WebViewNative.SetNavigationCompletedCallback(InstanceId, OnNavigationCompleted); + WebViewNative.SetDocumentTitleChangedCallback(InstanceId, OnDocumentTitleChanged); + WebViewNative.SetPermissionRequestedCallback(InstanceId, OnPermissionRequested); + } + + public void SetVirtualHostMapping(string hostName, string folderPath) + { + WebViewNative.SetVirtualHostMapping(InstanceId, hostName, folderPath); + } + + public void ReleaseFocus() + { + WebViewNative.ReleaseFocus(InstanceId); + } + + public void GetNonDefaultPermissionSettings(WebView_OnPermissionSettingFound settingFoundCallback) + { + permissionSettingFound = settingFoundCallback; + + WebViewNative.GetNonDefaultPermissionSettings(InstanceId, OnPermissionSettingFound); + } + + public void SetPermissionState(string origin, WebViewPermissionKind kind, WebViewPermissionState state) + { + WebViewNative.SetPermissionState(InstanceId, origin, (int)kind, (int)state); + } + + [MonoPInvokeCallback(typeof(WebViewNative.NavigationStartingDelegate))] + private static void OnNavigationStarting(IntPtr instanceId, Int64 navigationId, string uri) + { + WindowsWebView webView = WebViewSystem.FindWebView(instanceId) as WindowsWebView; + if (webView != null) + { + webView.UnityGameThreadContext.Post(_ => webView.NavigationStarting?.Invoke(navigationId, uri), null); + } + } + + [MonoPInvokeCallback(typeof(WebViewNative.NavigationCompletedDelegate))] + private static void OnNavigationCompleted(IntPtr instanceId, Int64 navigationId, bool succeeded) + { + WindowsWebView webView = WebViewSystem.FindWebView(instanceId) as WindowsWebView; + if (webView != null) + { + webView.UnityGameThreadContext.Post(_ => webView.NavigationCompleted?.Invoke(navigationId, succeeded), null); + } + } + + [MonoPInvokeCallback(typeof(WebViewNative.DocumentTitleChanged))] + private static void OnDocumentTitleChanged(IntPtr instanceId, string newTitle) + { + WindowsWebView webView = WebViewSystem.FindWebView(instanceId) as WindowsWebView; + if (webView != null) + { + webView.UnityGameThreadContext.Post(_ => webView.DocumentTitleChanged?.Invoke(newTitle), null); + } + } + + [MonoPInvokeCallback(typeof(WebViewNative.NonDefaultPermissionSettingEnumDelegate))] + private static void OnPermissionSettingFound(IntPtr instanceId, string origin, int kind, int state, bool enumerationComplete) + { + WindowsWebView webView = WebViewSystem.FindWebView(instanceId) as WindowsWebView; + if (webView != null) + { + webView.UnityGameThreadContext.Post(_ => webView.permissionSettingFound?.Invoke(origin, (WebViewPermissionKind)kind, (WebViewPermissionState)state, enumerationComplete), null); + } + } + + [MonoPInvokeCallback(typeof(WebViewNative.PermissionRequestedDelegate))] + private static bool OnPermissionRequested(IntPtr instanceId, string origin, bool userInitiated, int kind, IntPtr state) + { + bool handled = false; + + WindowsWebView webView = WebViewSystem.FindWebView(instanceId) as WindowsWebView; + if (webView != null) + { + WebViewPermissionState localState = WebViewPermissionState.Default; + + // We send move this to the Unity game thread synchronously because we need to see the 'handled' and 'state' properties before the native handler exits. + webView.UnityGameThreadContext.Send(_ => webView.PermissionRequested?.Invoke(origin, userInitiated, (WebViewPermissionKind)kind, ref localState, ref handled), null); + + if (handled) + { + Marshal.WriteInt32(state, (int)localState); + } + } + + return handled; + } + } +} diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Platform/WindowsWebView.cs.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Platform/WindowsWebView.cs.meta new file mode 100644 index 0000000..6e5397f --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Platform/WindowsWebView.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 63a347d7cf608a24caed926a40561c0d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins.meta new file mode 100644 index 0000000..b385b67 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3db0a2890f2bf1642a84e34797f7593b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/.npmignore b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/.npmignore new file mode 100644 index 0000000..5f65701 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/.npmignore @@ -0,0 +1 @@ +# Don't ignore anything for now \ No newline at end of file diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/managed.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/managed.meta new file mode 100644 index 0000000..6d5e7b4 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/managed.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ac7e806163001e04cbbd04053605227f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/managed/net45.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/managed/net45.meta new file mode 100644 index 0000000..010f6fb --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/managed/net45.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a861dceda725e4849a7865b99e1f84c7 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/managed/net45/Microsoft.Web.WebView2.Core.dll b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/managed/net45/Microsoft.Web.WebView2.Core.dll new file mode 100644 index 0000000..a770d5e Binary files /dev/null and b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/managed/net45/Microsoft.Web.WebView2.Core.dll differ diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/managed/net45/Microsoft.Web.WebView2.Core.dll.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/managed/net45/Microsoft.Web.WebView2.Core.dll.meta new file mode 100644 index 0000000..13d53b0 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/managed/net45/Microsoft.Web.WebView2.Core.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 499d267c203698d46882c55cff12daba +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 1 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-arm64.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-arm64.meta new file mode 100644 index 0000000..3ca47f4 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-arm64.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 50471c41f0fae1d45ac1d4337eb62c51 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-arm64/Microsoft.Web.WebView2.Core.Native.dll b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-arm64/Microsoft.Web.WebView2.Core.Native.dll new file mode 100644 index 0000000..c6149fe Binary files /dev/null and b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-arm64/Microsoft.Web.WebView2.Core.Native.dll differ diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-arm64/Microsoft.Web.WebView2.Core.Native.dll.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-arm64/Microsoft.Web.WebView2.Core.Native.dll.meta new file mode 100644 index 0000000..c27c15e --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-arm64/Microsoft.Web.WebView2.Core.Native.dll.meta @@ -0,0 +1,82 @@ +fileFormatVersion: 2 +guid: 1e6dbdaf5511f7743be2c90bf5761855 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 1 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux64: 1 + Exclude OSXUniversal: 1 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude WindowsStoreApps: 0 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: None + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 1 + settings: + CPU: ARM64 + DontProcess: false + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-arm64/MicrosoftWebViewUnityPlugin.dll b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-arm64/MicrosoftWebViewUnityPlugin.dll new file mode 100644 index 0000000..2457211 Binary files /dev/null and b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-arm64/MicrosoftWebViewUnityPlugin.dll differ diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-arm64/MicrosoftWebViewUnityPlugin.dll.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-arm64/MicrosoftWebViewUnityPlugin.dll.meta new file mode 100644 index 0000000..4cd6c45 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-arm64/MicrosoftWebViewUnityPlugin.dll.meta @@ -0,0 +1,82 @@ +fileFormatVersion: 2 +guid: 7c14a078c9da57d47b1e3f43727ba169 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 1 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux64: 1 + Exclude OSXUniversal: 1 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude WindowsStoreApps: 0 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: None + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 1 + settings: + CPU: ARM64 + DontProcess: false + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-arm64/WebView2Loader.dll b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-arm64/WebView2Loader.dll new file mode 100644 index 0000000..3d7eab1 Binary files /dev/null and b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-arm64/WebView2Loader.dll differ diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-arm64/WebView2Loader.dll.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-arm64/WebView2Loader.dll.meta new file mode 100644 index 0000000..fb2c11f --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-arm64/WebView2Loader.dll.meta @@ -0,0 +1,82 @@ +fileFormatVersion: 2 +guid: bfccdd82cfd6d3f4094cded04f3e20f3 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 1 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux64: 1 + Exclude OSXUniversal: 1 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude WindowsStoreApps: 0 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: None + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 1 + settings: + CPU: ARM64 + DontProcess: false + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x64.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x64.meta new file mode 100644 index 0000000..eef3952 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x64.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9071c203dedf7754aabb6d542e8fc2c4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x64/Microsoft.Web.WebView2.Core.Native.dll b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x64/Microsoft.Web.WebView2.Core.Native.dll new file mode 100644 index 0000000..2e238fc Binary files /dev/null and b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x64/Microsoft.Web.WebView2.Core.Native.dll differ diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x64/Microsoft.Web.WebView2.Core.Native.dll.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x64/Microsoft.Web.WebView2.Core.Native.dll.meta new file mode 100644 index 0000000..dbbc1ea --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x64/Microsoft.Web.WebView2.Core.Native.dll.meta @@ -0,0 +1,82 @@ +fileFormatVersion: 2 +guid: 73b74d7420508af4fb98cd379b1083b7 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 1 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux64: 1 + Exclude OSXUniversal: 1 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude WindowsStoreApps: 0 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: None + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 1 + settings: + CPU: X64 + DontProcess: false + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x64/MicrosoftWebViewUnityPlugin.dll b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x64/MicrosoftWebViewUnityPlugin.dll new file mode 100644 index 0000000..3ecdc3d Binary files /dev/null and b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x64/MicrosoftWebViewUnityPlugin.dll differ diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x64/MicrosoftWebViewUnityPlugin.dll.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x64/MicrosoftWebViewUnityPlugin.dll.meta new file mode 100644 index 0000000..7fa09e5 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x64/MicrosoftWebViewUnityPlugin.dll.meta @@ -0,0 +1,82 @@ +fileFormatVersion: 2 +guid: 1b2f7566fac7ada409c1ce919292d348 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 1 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux64: 1 + Exclude OSXUniversal: 1 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude WindowsStoreApps: 0 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: None + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 1 + settings: + CPU: X64 + DontProcess: false + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x64/WebView2Loader.dll b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x64/WebView2Loader.dll new file mode 100644 index 0000000..d631ae2 Binary files /dev/null and b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x64/WebView2Loader.dll differ diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x64/WebView2Loader.dll.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x64/WebView2Loader.dll.meta new file mode 100644 index 0000000..679357a --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x64/WebView2Loader.dll.meta @@ -0,0 +1,82 @@ +fileFormatVersion: 2 +guid: d9029473d858b1c489debf96891e80cf +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 1 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux64: 1 + Exclude OSXUniversal: 1 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude WindowsStoreApps: 0 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: None + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 1 + settings: + CPU: X64 + DontProcess: false + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x86.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x86.meta new file mode 100644 index 0000000..266eae8 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x86.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 01bca71c7323c9046a27c331523bb5bf +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x86/Microsoft.Web.WebView2.Core.Native.dll b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x86/Microsoft.Web.WebView2.Core.Native.dll new file mode 100644 index 0000000..9ed9e40 Binary files /dev/null and b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x86/Microsoft.Web.WebView2.Core.Native.dll differ diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x86/Microsoft.Web.WebView2.Core.Native.dll.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x86/Microsoft.Web.WebView2.Core.Native.dll.meta new file mode 100644 index 0000000..c5678ae --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x86/Microsoft.Web.WebView2.Core.Native.dll.meta @@ -0,0 +1,82 @@ +fileFormatVersion: 2 +guid: e7f4ed841884b7340b9bffd6a36c4d66 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 1 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux64: 1 + Exclude OSXUniversal: 1 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude WindowsStoreApps: 0 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: None + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 1 + settings: + CPU: X86 + DontProcess: false + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x86/MicrosoftWebViewUnityPlugin.dll b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x86/MicrosoftWebViewUnityPlugin.dll new file mode 100644 index 0000000..4bcf0f2 Binary files /dev/null and b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x86/MicrosoftWebViewUnityPlugin.dll differ diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x86/MicrosoftWebViewUnityPlugin.dll.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x86/MicrosoftWebViewUnityPlugin.dll.meta new file mode 100644 index 0000000..751ee12 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x86/MicrosoftWebViewUnityPlugin.dll.meta @@ -0,0 +1,82 @@ +fileFormatVersion: 2 +guid: 9a9d0c13e02e29c42ae91179d5556ed5 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 1 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux64: 1 + Exclude OSXUniversal: 1 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude WindowsStoreApps: 0 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: None + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 1 + settings: + CPU: X86 + DontProcess: false + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x86/WebView2Loader.dll b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x86/WebView2Loader.dll new file mode 100644 index 0000000..4116ec1 Binary files /dev/null and b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x86/WebView2Loader.dll differ diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x86/WebView2Loader.dll.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x86/WebView2Loader.dll.meta new file mode 100644 index 0000000..a62e30a --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/uwp-x86/WebView2Loader.dll.meta @@ -0,0 +1,82 @@ +fileFormatVersion: 2 +guid: 631aeaf14126eca4cbdfc617c95c66d1 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 1 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux64: 1 + Exclude OSXUniversal: 1 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude WindowsStoreApps: 0 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: None + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 1 + settings: + CPU: X86 + DontProcess: false + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x64.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x64.meta new file mode 100644 index 0000000..8b0773e --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x64.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7f524ee4df47be9459e041cbb5d4854e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x64/MicrosoftWebViewUnityPlugin.dll b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x64/MicrosoftWebViewUnityPlugin.dll new file mode 100644 index 0000000..d39e80b Binary files /dev/null and b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x64/MicrosoftWebViewUnityPlugin.dll differ diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x64/MicrosoftWebViewUnityPlugin.dll.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x64/MicrosoftWebViewUnityPlugin.dll.meta new file mode 100644 index 0000000..332cfe7 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x64/MicrosoftWebViewUnityPlugin.dll.meta @@ -0,0 +1,82 @@ +fileFormatVersion: 2 +guid: e701673a2abddf348abac14a9173e4a3 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 1 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 0 + Exclude Linux64: 0 + Exclude OSXUniversal: 0 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 0 + Exclude WindowsStoreApps: 1 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: Windows + - first: + Standalone: Linux64 + second: + enabled: 1 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 1 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 1 + settings: + CPU: x86_64 + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + DontProcess: false + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x64/WebView2Loader.dll b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x64/WebView2Loader.dll new file mode 100644 index 0000000..d631ae2 Binary files /dev/null and b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x64/WebView2Loader.dll differ diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x64/WebView2Loader.dll.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x64/WebView2Loader.dll.meta new file mode 100644 index 0000000..7dc6922 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x64/WebView2Loader.dll.meta @@ -0,0 +1,82 @@ +fileFormatVersion: 2 +guid: 1ed1a2436365d094d8046cd0147e60d5 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 1 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 0 + Exclude Linux64: 0 + Exclude OSXUniversal: 0 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 0 + Exclude WindowsStoreApps: 1 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: Windows + - first: + Standalone: Linux64 + second: + enabled: 1 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 1 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 1 + settings: + CPU: x86_64 + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + DontProcess: false + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x86.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x86.meta new file mode 100644 index 0000000..d86d1ea --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x86.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 235916128c5f98a4ebdb608fe9750ac7 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x86/MicrosoftWebViewUnityPlugin.dll b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x86/MicrosoftWebViewUnityPlugin.dll new file mode 100644 index 0000000..6ed4b1f Binary files /dev/null and b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x86/MicrosoftWebViewUnityPlugin.dll differ diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x86/MicrosoftWebViewUnityPlugin.dll.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x86/MicrosoftWebViewUnityPlugin.dll.meta new file mode 100644 index 0000000..8f1a7e5 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x86/MicrosoftWebViewUnityPlugin.dll.meta @@ -0,0 +1,82 @@ +fileFormatVersion: 2 +guid: 0b8203b2772ba7547bdd21766503c388 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 1 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 0 + Exclude Linux64: 0 + Exclude OSXUniversal: 0 + Exclude WebGL: 1 + Exclude Win: 0 + Exclude Win64: 1 + Exclude WindowsStoreApps: 1 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + CPU: x86 + DefaultValueInitialized: true + OS: Windows + - first: + Standalone: Linux64 + second: + enabled: 1 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 1 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 1 + settings: + CPU: x86 + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: None + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + DontProcess: false + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x86/WebView2Loader.dll b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x86/WebView2Loader.dll new file mode 100644 index 0000000..4116ec1 Binary files /dev/null and b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x86/WebView2Loader.dll differ diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x86/WebView2Loader.dll.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x86/WebView2Loader.dll.meta new file mode 100644 index 0000000..48d4040 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Plugins/win32-x86/WebView2Loader.dll.meta @@ -0,0 +1,82 @@ +fileFormatVersion: 2 +guid: d95daac59e8989844bec2d7b702a9005 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 1 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 0 + Exclude Linux64: 0 + Exclude OSXUniversal: 0 + Exclude WebGL: 1 + Exclude Win: 0 + Exclude Win64: 1 + Exclude WindowsStoreApps: 1 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + CPU: x86 + DefaultValueInitialized: true + OS: Windows + - first: + Standalone: Linux64 + second: + enabled: 1 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 1 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 1 + settings: + CPU: x86 + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: None + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + DontProcess: false + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Prefab.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Prefab.meta new file mode 100644 index 0000000..5d52ae1 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 29937cc855f3fda4e900756dc58f5229 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Prefab/Materials.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Prefab/Materials.meta new file mode 100644 index 0000000..24a2a42 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Prefab/Materials.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 141beee4154bf4c45a611bc8f6853b0b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Prefab/Materials/UnlitWebView.mat b/com.microsoft.mixedreality.webview.unity/Runtime/Prefab/Materials/UnlitWebView.mat new file mode 100644 index 0000000..90c08ee --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Prefab/Materials/UnlitWebView.mat @@ -0,0 +1,107 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: UnlitWebView + m_Shader: {fileID: 4800000, guid: 442758c1158e9b84682640eb7fdecc0e, type: 3} + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 0 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _BlendOp: 0 + - _Brightness: 1 + - _BumpScale: 1 + - _CameraFadingEnabled: 0 + - _CameraFarFadeDistance: 2 + - _CameraNearFadeDistance: 1 + - _ColorMask: 15 + - _ColorMode: 0 + - _Cull: 2 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DistortionBlend: 0.5 + - _DistortionEnabled: 0 + - _DistortionStrength: 1 + - _DistortionStrengthScaled: 0 + - _DstBlend: 0 + - _EmissionEnabled: 0 + - _FlipbookMode: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _LightingEnabled: 0 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SoftParticlesEnabled: 0 + - _SoftParticlesFarFadeDistance: 1 + - _SoftParticlesNearFadeDistance: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _Stencil: 0 + - _StencilComp: 8 + - _StencilOp: 0 + - _StencilReadMask: 255 + - _StencilWriteMask: 255 + - _UVSec: 0 + - _UseUIAlphaClip: 0 + - _ZWrite: 1 + m_Colors: + - _CameraFadeParams: {r: 0, g: Infinity, b: 0, a: 0} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _ColorAddSubDiff: {r: 0, g: 0, b: 0, a: 0} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _SoftParticleFadeParams: {r: 0, g: 0, b: 0, a: 0} + m_BuildTextureStacks: [] diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Prefab/Materials/UnlitWebView.mat.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Prefab/Materials/UnlitWebView.mat.meta new file mode 100644 index 0000000..a31c61d --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Prefab/Materials/UnlitWebView.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6fc857917aaa19248a79c874940efe66 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Prefab/Materials/UnlitWebView.shader b/com.microsoft.mixedreality.webview.unity/Runtime/Prefab/Materials/UnlitWebView.shader new file mode 100644 index 0000000..76798ff --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Prefab/Materials/UnlitWebView.shader @@ -0,0 +1,61 @@ +Shader "WebView/Unlit" +{ + Properties + { + _Brightness ("Brightness", Range(0.0, 2.0)) = 1.0 + _MainTex ("Texture", 2D) = "white" {} + } + SubShader + { + Tags { "RenderType"="Opaque" } + LOD 100 + + Pass + { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + // make fog work + #pragma multi_compile_fog + + #include "UnityCG.cginc" + + struct appdata + { + float4 vertex : POSITION; + float2 uv : TEXCOORD0; + }; + + struct v2f + { + float2 uv : TEXCOORD0; + UNITY_FOG_COORDS(1) + float4 vertex : SV_POSITION; + }; + + float _Brightness; + sampler2D _MainTex; + float4 _MainTex_ST; + + v2f vert (appdata v) + { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.uv = TRANSFORM_TEX(v.uv, _MainTex); + UNITY_TRANSFER_FOG(o,o.vertex); + return o; + } + + fixed4 frag (v2f i) : SV_Target + { + // sample the texture + fixed4 col = tex2D(_MainTex, i.uv); + col.rgb = GammaToLinearSpace(col.rgb) * _Brightness; + // apply fog + UNITY_APPLY_FOG(i.fogCoord, col); + return col; + } + ENDCG + } + } +} diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Prefab/Materials/UnlitWebView.shader.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Prefab/Materials/UnlitWebView.shader.meta new file mode 100644 index 0000000..a150c56 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Prefab/Materials/UnlitWebView.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 442758c1158e9b84682640eb7fdecc0e +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Prefab/WebView.prefab b/com.microsoft.mixedreality.webview.unity/Runtime/Prefab/WebView.prefab new file mode 100644 index 0000000..bee8f14 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Prefab/WebView.prefab @@ -0,0 +1,112 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &2311476450002457713 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3231283774461358941} + - component: {fileID: 8889484358565923431} + - component: {fileID: 3762268489012255157} + - component: {fileID: 1923600390656491344} + - component: {fileID: 6397544354392829286} + m_Layer: 0 + m_Name: WebView + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &3231283774461358941 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2311476450002457713} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &8889484358565923431 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2311476450002457713} + m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &3762268489012255157 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2311476450002457713} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 6fc857917aaa19248a79c874940efe66, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!65 &1923600390656491344 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2311476450002457713} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 6.1232336e-17} + m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &6397544354392829286 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2311476450002457713} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a53eeca6aca1dba4fb85792a6ab6b2ca, type: 3} + m_Name: + m_EditorClassIdentifier: + currentURL: https://www.microsoft.com + webViewPrefab: {fileID: 0} diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/Prefab/WebView.prefab.meta b/com.microsoft.mixedreality.webview.unity/Runtime/Prefab/WebView.prefab.meta new file mode 100644 index 0000000..5606edb --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/Prefab/WebView.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 4410a2a17e71713438d8cf4ebc93d9a4 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/WebView.cs b/com.microsoft.mixedreality.webview.unity/Runtime/WebView.cs new file mode 100644 index 0000000..720ed0f --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/WebView.cs @@ -0,0 +1,348 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// + +namespace Microsoft.MixedReality.WebView +{ + using System; + using System.Threading.Tasks; + using UnityEngine; + using UnityEngine.Scripting; +#if UNITY_EDITOR + using UnityEditor; +#endif + + /// + /// A high-level script that facilitates adding WebView's to your scene. + /// Use either the built-in WebView prefab or your own quad to position and + /// render your WebView's contents with the help of WebView.cs. + /// + [Preserve] + [AddComponentMenu("WebView")] + // Necessary because WebViewSystem attaches the WebView texture to + // the GameObject's renderer's material. + [RequireComponent(typeof(Renderer))] + public class WebView : MonoBehaviour + { + [Tooltip("Scale the brightness. A value of 1 matches what you see in your browser.")] + [SerializeField] + [OnRangeChangedCall(0f, 2f, "OnBrightnessScaleChanged")] + private float brightnessScale = 1.0f; + + public enum ImageQuality + { + Low, + Good, + Great, + Excellent + } + [Tooltip("Configure image quality. Higher quality looks better but can decrease performance.")] + [SerializeField] + [OnChangedCall("OnImageQualityChanged")] + private ImageQuality imageQuality = ImageQuality.Low; + + private float TextureScale + { + get + { + if (webView is IWithContentScale) + { + switch (this.imageQuality) + { + case ImageQuality.Low: + return 1; + case ImageQuality.Good: + return 3; + case ImageQuality.Great: + return 6; + case ImageQuality.Excellent: + return 9; + } + } + return 1; + } + } + + [Tooltip("The URL that is first loaded when the WebView initializes in the scene.")] + [SerializeField] + [OnChangedCall("OnAbsoluteUrlChanged")] + private string currentURL = "https://www.microsoft.com"; + + /// + /// This flag signifies if the current url field is unsynced with the IWebView instance. + /// + private bool currentURLDirty = false; + + private IWebView webView = null; + + private Exception creationException = null; + + /// + /// Invoked once the WebView plugin instance is initialized and has begun loading the currentUrl. + /// + public event EventHandler WebViewReady; + + private readonly TaskCompletionSource webViewTCS = new TaskCompletionSource(); + + /// + /// An awaitable Task that returns the WebView's IWebView instance after it has been initialized. + /// + public Task WebViewTask + { + get { return webViewTCS.Task; } + } + + /// + /// Invoked once the WebView has finished navigating to a URL. + /// The event arguments are a tuple of the WebView instance and the URL to which it navigated. + /// + public event EventHandler<(IWebView, string)> WebViewNavigated; + + public event EventHandler WebViewCreationFailed; + + public Exception WebViewCreationException { get { return creationException; } } + + /// + /// Gets the URL currently loaded by the WebView. + /// + public Uri CurrentURL + { + get { return this.webView?.Page; } + } + + public void Awake() + { + this.CreateAndConfigureWebView(); + this.UpdateBrightness(); + } + + public void PostMessage(string message) + { + if (this.webView is IWithPostMessage withPostMessage) + { + withPostMessage.PostMessage(message); + } + } + + public void NavigateToString(string htmlContent) + { + if (this.webView is IWithHTMLInjection withHTMLInjection) + { + withHTMLInjection.LoadHTMLContent(htmlContent); + } + } + + /// + /// Loads an absolute URL, such as about:blank or https://www.microsoft.com + /// The URL string will be validated to make sure it's well-formed and absolute. + /// If the internal WebView instance is not yet initialized, the load will be enqueued for when the instance is ready. + /// Calls to this method will not overwrite currentUrl, they will load in sequence. + /// + /// The URL to load. + public void Load(string url) + { + if (string.IsNullOrWhiteSpace(url)) + { + Debug.Log($"Current url is empty. Ignoring load request."); + } + else + { + this.Load(new Uri(url)); + } + } + + /// + /// Uri overload for Load(string url). + /// + /// The URI to load. + /// If the URI is invalid. + public void Load(Uri uri) + { + if (uri is null) + { + throw new ArgumentNullException(nameof(uri)); + } + + var absolutePath = uri.AbsoluteUri; + if (!uri.IsWellFormedOriginalString() || !uri.IsAbsoluteUri) + { + throw new ArgumentException($"\"{absolutePath}\" is invalid: it must be a well-formed, absolute Uri."); + } + + if (this.webView is null) + { + // Enqueue a load on the webview. + this.WebViewReady += new EventHandler((object s, IWebView wv) => + { + wv.Load(uri); + }); + } + else + { + this.webView.Load(uri); + } + } + + public IWebView GetWebView() + { + return this.webView; + } + + /// + /// Takes a callback that is invoked either immediately if the IWebView instance has already been created, or once the IWebView instance is created. + /// + /// The callback, which can be a lambda or any function taking an IWebView instance as the only argument. + public void GetWebViewWhenReady(Action callback) + { + if (this.webView is null) + { + this.WebViewReady += (object s, IWebView wv) => callback(wv); + } + else + { + callback(this.webView); + } + } + + public void GetWebViewCreationFailed(Action callback) + { + if (this.webView is null && this.creationException is null) + { + this.WebViewCreationFailed += (object s, Exception e) => callback(e); + } + else if (this.creationException is not null) + { + callback(this.creationException); + } + } + + private void OnAbsoluteUrlChanged() + { + this.currentURLDirty = !this.CurrentURL?.AbsoluteUri.Equals(this.currentURL) ?? false; + } + + private void OnImageQualityChanged() + { + if (webView is IWithContentScale) + { + MatchTextureSizeToQuad(); + } + } + + private void OnBrightnessScaleChanged() + { + this.UpdateBrightness(); + } + + private void UpdateBrightness() + { + GetComponent().material.SetFloat("_Brightness", brightnessScale); + } + + private void CreateAndConfigureWebView() + { + string parentHWNDHint = null; +#if UNITY_EDITOR_WIN + parentHWNDHint = "UnityEditor.GameView:UnityGUIViewWndClass"; +#endif + var newWebView = WebViewSystem.CreateWebView(this.gameObject, 1280, 720, parentHWNDHint); + if (newWebView is null) + { + creationException = new Exception("Failed to create webview"); + this.WebViewCreationFailed?.Invoke(this, creationException); + return; + } + + newWebView.Navigated += path => + { + this.currentURL = path; + this.currentURLDirty = false; + this.WebViewNavigated?.Invoke(this, (newWebView, path)); + }; + + newWebView.OnceCreated.ContinueWith((task) => + { + // Disposed before the new webview could be created. + if (this == null) + { + newWebView.Dispose(); + } + else if (task.IsFaulted) + { + creationException = task.Exception; + this.WebViewCreationFailed?.Invoke(this, creationException); + } + else + { + this.webView = newWebView; + MatchTextureSizeToQuad(); + this.WebViewReady?.Invoke(this, this.webView); + this.webViewTCS.SetResult(this.webView); + } + }, TaskScheduler.FromCurrentSynchronizationContext()); + this.Load(this.currentURL); + } + + private void MatchTextureSizeToQuad() + { + // Adjust width and height + Vector3 lossyScale = transform.lossyScale; + float scaleHorizontal = lossyScale.x; + // Sometimes quads are aligned with their vertical component on y, and some on z. + float scaleVertical = Math.Max(lossyScale.y, lossyScale.z); + int smallDimension = (int)(720 * TextureScale); + + // For D3D11, texture dimensions must be between 1 and 16384, inclusively. + // This is a reasonable cap for all platforms. + int maxSize = 16384; + + int width, height; + bool landscape = scaleHorizontal > scaleVertical; + var aspectRatio = landscape ? scaleHorizontal / scaleVertical : scaleVertical / scaleHorizontal; + int bigDimension = (int)(smallDimension * aspectRatio); + + // Adjust if the larger dimension is too big. + if (bigDimension > maxSize) + { + bigDimension = maxSize; + smallDimension = (int)(bigDimension / aspectRatio); + } + + width = landscape ? bigDimension : smallDimension; + height = landscape ? smallDimension : bigDimension; + + (webView as IWithContentScale)?.SetContentScale(TextureScale); + webView.Resize(width, height); + } + + private void OnDestroy() + { + this.webView?.Dispose(); + } + +#if UNITY_EDITOR + [CustomEditor(typeof(WebView))] + private class WebViewInspector : Editor + { + public override void OnInspectorGUI() + { + var webViewComponent = (WebView)this.target; + DrawDefaultInspector(); + if (webViewComponent.currentURLDirty) + { + if (GUILayout.Button("Navigate")) + { + webViewComponent.Load(webViewComponent.currentURL); + } + + if (GUILayout.Button("Cancel")) + { + webViewComponent.currentURL = webViewComponent.CurrentURL.AbsoluteUri; + webViewComponent.currentURLDirty = false; + } + } + } + } +#endif + } +} \ No newline at end of file diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/WebView.cs.meta b/com.microsoft.mixedreality.webview.unity/Runtime/WebView.cs.meta new file mode 100644 index 0000000..4ee8934 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/WebView.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a53eeca6aca1dba4fb85792a6ab6b2ca +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/WebViewEventModifiersState.cs b/com.microsoft.mixedreality.webview.unity/Runtime/WebViewEventModifiersState.cs new file mode 100644 index 0000000..721244b --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/WebViewEventModifiersState.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Originally written in the EDT/MeshBrowser project by paarnese + +namespace Microsoft.MixedReality.WebView +{ + public class WebViewEventModifiersState + { + private bool swigCMemOwn; + + public bool IsAltDown { get; set; } + + public bool IsCapsOn { get; set; } + + public bool IsCtrlDown { get; set; } + + public bool IsMetaDown { get; set; } + + public bool IsNumLockOn { get; set; } + + public bool IsShiftDown { get; set; } + } +} diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/WebViewEventModifiersState.cs.meta b/com.microsoft.mixedreality.webview.unity/Runtime/WebViewEventModifiersState.cs.meta new file mode 100644 index 0000000..510c967 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/WebViewEventModifiersState.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3fb54385fdcd8b24fad4f19793458869 +timeCreated: 1440212729 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/WebViewMouseEventData.cs b/com.microsoft.mixedreality.webview.unity/Runtime/WebViewMouseEventData.cs new file mode 100644 index 0000000..e99775b --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/WebViewMouseEventData.cs @@ -0,0 +1,77 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Originally written in the EDT/MeshBrowser project by paarnese + +namespace Microsoft.MixedReality.WebView +{ + public class WebViewMouseEventData + { + public enum TertiaryAxisDevice + { + None = -1, + PointingDevice = 0, + Dpad + } + + public enum DeviceType + { + Mouse = 1, + // Pointer or ray-based controller + Pointer = 2, + } + + public enum EventType + { + MouseMove = 0, + MouseDown = 1, + MouseUp = 2, + MouseWheel = 3, + } + + public enum MouseButton + { + ButtonNone = -1, + ButtonLeft = 0, + ButtonMiddle = 1, + ButtonRight = 2, + } + + public enum WheelBehaviorHint + { + RelativeAndButtonDown = 0, + Absolute = 1 + } + + public MouseButton Button { get; set; } + + public WebViewEventModifiersState Modifiers { get; set; } + + public WebViewEventMouseModifiersState MouseModifiers { get; set; } + + public EventType Type { get; set; } + + public DeviceType Device { get; set; } + + public float WheelX { get; set; } + + public float WheelY { get; set; } + + public int X { get; set; } + + public int Y { get; set; } + + public WheelBehaviorHint WheelHint { get; set; } = WheelBehaviorHint.RelativeAndButtonDown; + + public TertiaryAxisDevice TertiaryAxisDeviceType { get; set; } + } + + public class WebViewEventMouseModifiersState + { + public bool IsLeftButtonDown { get; set; } + + public bool IsMiddleButtonDown { get; set; } + + public bool IsRightButtonDown { get; set; } + } +} \ No newline at end of file diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/WebViewMouseEventData.cs.meta b/com.microsoft.mixedreality.webview.unity/Runtime/WebViewMouseEventData.cs.meta new file mode 100644 index 0000000..2f919d7 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/WebViewMouseEventData.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8cf54a631d8828247bfe329b6dc22acb +timeCreated: 1440212729 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/WebViewSystem.cs b/com.microsoft.mixedreality.webview.unity/Runtime/WebViewSystem.cs new file mode 100644 index 0000000..5ed677a --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/WebViewSystem.cs @@ -0,0 +1,251 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// + +namespace Microsoft.MixedReality.WebView +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Threading; + using UnityEngine; + + public class WebViewSystem : MonoBehaviour + { + /// + /// A delegate you can register to WebViewSystem to create custom implementations of IWebView.
+ /// Register your delegate with WebViewSystem.RegisterCreateWebViewDelegate
+ /// The delegates registered to WebViewSystem are called in order of registration.
+ /// If you return null, WebViewSystem will fall through to the next registered delegate.
+ /// If all registered delegates return null, WebViewSystem will attempt to provide a default implementation.
+ ///
+ /// + /// The GameObject to which system-wide singleton scripts should be attached. + /// This GameObject is destroyed when all active IWebView instances are destroyed, + /// and recreated when new IWebView instances are created. + /// + /// The GameObject to which the IWebView implementation will be bound. + /// The width (in pixels) of the requested IWebView. + /// The height (in pixels) of the requested IWebView. + /// The custom IWebView implementation, or null as a fallthrough case. + public delegate IWebView CreateWebViewDelegate(GameObject systemSingleton, GameObject webView, int width, int height); + private static readonly List createWebViewDelegates = new List(); + + /// + /// A delegate you can register to WebViewSystem to add components to any GameObject hosting an IWebView.
+ /// Register your delegate with WebViewSystem.RegisterComponentWebViewDelegate.
+ /// The delegates registered to WebViewSystem are called in order of registration, after the CreateWebViewDelegates run.
+ ///
+ /// + /// The GameObject to which system-wide singleton scripts should be attached. + /// This GameObject is destroyed when all active IWebView instances are destroyed, + /// and recreated when new IWebView instances are created. + /// + /// The GameObject that holds the WebView component. + public delegate void ComponentWebViewDelegate(GameObject systemSingleton, GameObject webView); + private static readonly List componentWebViewDelegates = new List(); + + internal static Thread AppThread { get; private set; } + private static readonly Dictionary viewMap = new Dictionary(); + + private static GameObject singleton; + + private static void RegisterUniqueDelegate(List list, T del) + { + if (del is null) + { + throw new ArgumentNullException(); + } + + if (!list.Contains(del)) + { + list.Add(del); + } + else + { + throw new ArgumentException("Delegate is already registered to WebViewSystem!"); + } + } + + public static void UnregisterUniqueDelegate(List list, T del) + { + if (del is null) + { + throw new ArgumentNullException(); + } + + if (list.Contains(del)) + { + list.Remove(del); + } + else + { + throw new ArgumentException("Delegate is not registered to WebViewSystem!"); + } + } + + /// + /// Registers a ComponentWebViewDelegate for adding plugin components to WebViews, + /// so that it will be called by WebViewSystem.CreateWebView. + /// + /// The delegate that will be called in the order of its registration (FIFO). + /// If the delegate is already registered. + /// If the delegate is null. + public static void RegisterCreateWebViewDelegate(CreateWebViewDelegate del) + { + RegisterUniqueDelegate(createWebViewDelegates, del); + } + + /// + /// Unregisters a CreateWebViewDelegate for creating custom WebViews, + /// so that it will no longer get called by WebViewSystem.CreateWebView. + /// + /// The delegate to unregister from the list. + /// If the delegate is already registered. + /// If the delegate is null. + public static void UnregisterCreateWebViewDelegate(CreateWebViewDelegate del) + { + UnregisterUniqueDelegate(createWebViewDelegates, del); + } + + /// + /// Registers a CreateWebViewDelegate for creating custom WebViews, + /// so that it will be called by WebViewSystem.CreateWebView. + /// + /// The delegate to unregister from the list. + /// If the delegate is already registered. + /// If the delegate is null. + public static void RegisterComponentWebViewDelegate(ComponentWebViewDelegate del) + { + RegisterUniqueDelegate(componentWebViewDelegates, del); + } + + /// + /// Unregisters a ComponentWebViewDelegate for adding plugin components to WebViews, + /// so that it will no longer get called by WebViewSystem.CreateWebView. + /// + /// The delegate to unregister from the list. + /// If the delegate is already registered. + /// If the delegate is null. + public static void UnregisterComponentWebViewDelegate(ComponentWebViewDelegate del) + { + UnregisterUniqueDelegate(componentWebViewDelegates, del); + } + + internal static IWebView CreateWebView(GameObject gameObject, int width, int height, string parentHWNDHint) + { + if (singleton == null && gameObject != null) + { + singleton = new GameObject("WebViewSystem"); + singleton.AddComponent(); + } + + IWebView webView = null; + // Go through all the delegates in order of registration (FIFO). + foreach (var del in createWebViewDelegates) + { + webView = del(singleton, gameObject, width, height); + if (webView != null) + { + break; + } + } + // If none of the delegates were capable of producing an IWebView, fallback to default. + webView ??= CreateWebViewDefault(gameObject, width, height, parentHWNDHint); + + if (webView == null) + { + throw new Exception("Could not create an instance of IWebView! Perhaps an implementation is missing?"); + } + + // Run the component plugin delegates. + foreach (var del in componentWebViewDelegates) + { + del(singleton, gameObject); + } + + return webView; + } + + + private static IWebView CreateWebViewDefault(GameObject gameObject, int width, int height, string parentHWNDHint) + { +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || UNITY_WSA + WindowsWebView windowsWebView = new WindowsWebView(gameObject, width, height, parentHWNDHint); + if (windowsWebView.InstanceId != IntPtr.Zero) + { + viewMap.Add(windowsWebView.InstanceId, windowsWebView); + } + else + { + Debug.LogError("InstanceId is null, indicating failure to create the native WebView."); + } + return windowsWebView; +#elif UNITY_ANDROID + AndroidWebView androidWebView = new AndroidWebView(gameObject, width, height); + viewMap.Add(androidWebView.InstanceId, androidWebView); + return androidWebView; +#else + return null; +#endif + } + + internal static void ViewDestroyed(IntPtr instanceId) + { + viewMap.Remove(instanceId); + if (viewMap.Count() == 0) + { + DestroySingleton(); + } + } + + internal static IWebView FindWebView(IntPtr instanceId) + { + return viewMap.TryGetValue(instanceId, out var view) ? view : null; + } + + private void Awake() + { + AppThread = Thread.CurrentThread; + } + + private IEnumerator Start() + { + yield return StartCoroutine("CallPluginAtEndOfFrames"); + } + + private void OnDestroy() + { + viewMap.Clear(); + DestroySingleton(); + } + + private static void DestroySingleton() + { + if (singleton != null) { + Destroy(singleton); + singleton = null; + } + } + + private IEnumerator CallPluginAtEndOfFrames() + { + while (true) + { + // Wait until all frame rendering is done + yield return new WaitForEndOfFrame(); + WebViewSystem.RenderFrame(); + } + } + + public static void RenderFrame() + { + // Issue a plugin event with arbitrary integer identifier. + // The plugin can distinguish between different + // things it needs to do based on this ID. + // For our plugin, it does not matter which ID we pass here. + GL.IssuePluginEvent(WebViewNative.GetRenderEventFunc(), 1); + } + } +} \ No newline at end of file diff --git a/com.microsoft.mixedreality.webview.unity/Runtime/WebViewSystem.cs.meta b/com.microsoft.mixedreality.webview.unity/Runtime/WebViewSystem.cs.meta new file mode 100644 index 0000000..75ae9d8 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/Runtime/WebViewSystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: aadb010fb88146943bf47a2d5da19d25 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/link.xml b/com.microsoft.mixedreality.webview.unity/link.xml new file mode 100644 index 0000000..cd4dc47 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/link.xml @@ -0,0 +1,3 @@ + + + diff --git a/com.microsoft.mixedreality.webview.unity/link.xml.meta b/com.microsoft.mixedreality.webview.unity/link.xml.meta new file mode 100644 index 0000000..73c823a --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/link.xml.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 72d02c5372f1c0149b2a4eb15b4a8b12 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.microsoft.mixedreality.webview.unity/package.json b/com.microsoft.mixedreality.webview.unity/package.json new file mode 100644 index 0000000..ed30c09 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/package.json @@ -0,0 +1,11 @@ +{ + "name": "com.microsoft.mixedreality.webview.unity", + "version": "0.22.7-pre.1", + "displayName": "Microsoft Mixed Reality WebView", + "description": "A cross-platform Unity WebView component for Microsoft Mixed Reality", + "unity": "2021.3", + "unityRelease": "26f1", + "author": "Microsoft", + "dependencies": { + } +} diff --git a/com.microsoft.mixedreality.webview.unity/package.json.meta b/com.microsoft.mixedreality.webview.unity/package.json.meta new file mode 100644 index 0000000..5a453d2 --- /dev/null +++ b/com.microsoft.mixedreality.webview.unity/package.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 158038d7ecb68034ab59b0352311fe0d +PackageManifestImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: