WindowsWebPlugin.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * Copyright (c) 2021 Vuplex Inc. All rights reserved.
  3. *
  4. * Licensed under the Vuplex Commercial Software Library License, you may
  5. * not use this file except in compliance with the License. You may obtain
  6. * a copy of the License at
  7. *
  8. * https://vuplex.com/commercial-library-license
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #if (UNITY_STANDALONE_WIN && !UNITY_EDITOR) || UNITY_EDITOR_WIN
  17. using System;
  18. using System.Runtime.InteropServices;
  19. using UnityEngine;
  20. namespace Vuplex.WebView {
  21. /// <summary>
  22. /// The Windows `IWebPlugin` implementation.
  23. /// </summary>
  24. class WindowsWebPlugin : StandaloneWebPlugin, IWebPlugin {
  25. public static WindowsWebPlugin Instance {
  26. get {
  27. if (_instance == null) {
  28. _instance = (WindowsWebPlugin) new GameObject("WindowsWebPlugin").AddComponent<WindowsWebPlugin>();
  29. DontDestroyOnLoad(_instance.gameObject);
  30. }
  31. return _instance;
  32. }
  33. }
  34. public WebPluginType Type {
  35. get {
  36. return WebPluginType.Windows;
  37. }
  38. }
  39. public virtual IWebView CreateWebView() {
  40. return WindowsWebView.Instantiate();
  41. }
  42. static WindowsWebPlugin _instance;
  43. void OnValidate() {
  44. WindowsWebView.ValidateGraphicsApi();
  45. }
  46. }
  47. }
  48. #endif