WindowsWebPlugin.cs 1.5 KB

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