IWithNative2DMode.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. using System.Threading.Tasks;
  15. using UnityEngine;
  16. namespace Vuplex.WebView {
  17. /// <summary>
  18. /// An interface implemented by a webview if it supports Native 2D Mode, which makes it
  19. /// so that 3D WebView positions a native 2D webview in front of the Unity game view instead
  20. /// of displaying web content as a texture in the Unity scene.
  21. /// For more info, please see [this article](https://support.vuplex.com/articles/native-2d-mode).
  22. /// </summary>
  23. /// <seealso cref="CanvasWebViewPrefab.Native2DModeEnabled"/>
  24. public interface IWithNative2DMode {
  25. /// <summary>
  26. /// Gets a value indicating whether the webview is running in Native 2D Mode.
  27. /// </summary>
  28. /// <seealso cref="CanvasWebViewPrefab.Native2DModeEnabled"/>
  29. bool Native2DModeEnabled { get; }
  30. /// <summary>
  31. /// Gets the native 2D webview's rect on the screen, in pixels.
  32. /// </summary>
  33. /// <seealso cref="IWithNative2DMode.SetRect"/>
  34. Rect Rect { get; }
  35. /// <summary>
  36. /// Gets a value indicating whether the native 2D webview is visible.
  37. /// The default is `true`.
  38. /// </summary>
  39. /// <seealso cref="CanvasWebViewPrefab.Visible"/>
  40. /// <seealso cref="IWithNative2DMode.SetVisible"/>
  41. bool Visible { get; }
  42. /// <summary>
  43. /// Brings the native webview to the front of the view hierarchy.
  44. /// A webview is automatically placed in the front when it's created,
  45. /// but this method can be used to control which webview is in front
  46. /// if your scene contains multiple 2D webviews.
  47. /// </summary>
  48. /// <remarks>
  49. /// This method is currently not supported on UWP.
  50. /// </remarks>
  51. void BringToFront();
  52. /// <summary>
  53. /// Initializes the webview in Native 2D Mode. This method is to be used instead
  54. /// of IWebView.Init() for initialization.
  55. /// </summary>
  56. Task InitInNative2DMode(Rect rect);
  57. /// <summary>
  58. /// Sets whether the native 2D webview's pinch-to-zoom behavior
  59. /// is enabled. The default is `true`.
  60. /// </summary>
  61. void SetNativeZoomEnabled(bool enabled);
  62. /// <summary>
  63. /// Sets the native 2D webview's rect on the screen, in pixels.
  64. /// </summary>
  65. /// <seealso cref="IWithNative2DMode.Rect"/>
  66. void SetRect(Rect rect);
  67. /// <summary>
  68. /// Sets whether the native 2D webview is visible.
  69. /// </summary>
  70. /// <seealso cref="CanvasWebViewPrefab.Visible"/>
  71. /// <seealso cref="IWithNative2DMode.Visible"/>
  72. void SetVisible(bool visible);
  73. }
  74. }