// Copyright (c) 2022 Vuplex Inc. All rights reserved.
//
// Licensed under the Vuplex Commercial Software Library License, you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// https://vuplex.com/commercial-library-license
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
namespace Vuplex.WebView {
///
/// IWebView is the primary interface for loading and interacting with web content.
/// It contains methods and properties for common browser-related functionality,
/// like LoadUrl(), GoBack(), Reload(), and ExecuteJavaScript().
///
///
///
/// To create an IWebView, instantiate a WebViewPrefab or CanvasWebViewPrefab. After
/// the prefab is initialized, you can access its IWebView via the WebViewPrefab.WebView property.
/// If your use case requires a high degree of customization, you can instead create
/// an IWebView outside of a prefab (to connect to your own custom GameObject) by
/// using Web.CreateWebView().
///
///
/// For additional functionality, you can cast an IWebView to an interface for a specific
/// feature, like IWithDownloads or IWithPopups. For a list of additional feature interfaces and
/// information about how to use them, see this page: https://developer.vuplex.com/webview/additional-interfaces
///
/// See also:
///
/// - WebViewPrefab: https://developer.vuplex.com/webview/WebViewPrefab
/// - CanvasWebViewPrefab: https://developer.vuplex.com/webview/CanvasWebViewPrefab
/// - Web (static methods): https://developer.vuplex.com/webview/Web
///
///
public interface IWebView {
///
/// Indicates that the page has requested to close (i.e. via window.close()).
///
///
///
/// await webViewPrefab.WaitUntilInitialized();
/// webViewPrefab.WebView.CloseRequested += (sender, eventArgs) => {
/// Debug.Log("Close requested");
/// };
///
///
event EventHandler CloseRequested;
///
/// Indicates that a message was logged to the JavaScript console.
///
///
/// The 3D WebView packages for Android with Gecko, iOS, and UWP have the following limitations:
///
/// -
/// Only messages explicitly passed to a console method like console.log() are included,
/// and other messages like uncaught errors or network errors aren't automatically included.
///
/// - Messages from iframes aren't included.
/// - Messages logged early when the page starts loading may be missed.
///
/// For Android Gecko, an alternative that avoids these limitations is to call
/// AndroidGeckoWebView.SetConsoleOutputEnabled().
///
///
///
/// await webViewPrefab.WaitUntilInitialized();
/// webViewPrefab.WebView.ConsoleMessageLogged += (sender, eventArgs) => {
/// Debug.Log($"Console message logged: [{eventArgs.Level}] {eventArgs.Message}");
/// };
///
///
///
/// Remote debugging
event EventHandler ConsoleMessageLogged;
///
/// Indicates when an input field has been focused or unfocused. This can be used,
/// for example, to determine when to show or hide an on-screen keyboard.
/// This event is also raised when a focused input field is clicked subsequent times.
/// Note that this event is currently only fired for input fields focused in the main frame
/// and is not fired for input fields in iframes.
///
///
///
/// await webViewPrefab.WaitUntilInitialized();
/// webViewPrefab.WebView.FocusedInputFieldChanged += (sender, eventArgs) => {
/// Debug.Log("Focused input field changed. Text input is focused: " + eventArgs.Type == FocusedInputFieldType.Text);
/// };
///
///
event EventHandler FocusedInputFieldChanged;
///
/// Indicates that the page load progress changed.
///
///
/// For 2D WebView for WebGL, LoadProgressChanged only indicates the ProgressChangeType.Started and Finished events,
/// and it's unable to indicate the Failed or Updated events.
///
///
///
/// await webViewPrefab.WaitUntilInitialized();
/// webViewPrefab.WebView.LoadProgressChanged += (sender, eventArgs) => {
/// Debug.Log($"Load progress changed: {eventArgs.Type}, {eventArgs.Progress}");
/// if (eventArgs.Type == ProgressChangeType.Finished) {
/// Debug.Log("The page finished loading");
/// }
/// };
///
///
///
event EventHandler LoadProgressChanged;
///
/// Indicates that JavaScript running in the page used the `window.vuplex.postMessage`
/// JavaScript API to emit a message to the Unity application. For more details, please see
/// [this support article](https://support.vuplex.com/articles/how-to-send-messages-from-javascript-to-c-sharp).
///
///
///
/// await webViewPrefab.WaitUntilInitialized();
/// // Add JavaScript to the page that sends a message.
/// webViewPrefab.WebView.PageLoadScripts.Add(@"
/// window.vuplex.postMessage('Hello from JavaScript!');
/// ");
/// webViewPrefab.WebView.MessageEmitted += (sender, eventArgs) => {
/// Debug.Log("Message received from JavaScript: " + eventArgs.Value);
/// };
///
///
///
///
event EventHandler> MessageEmitted;
///
/// Indicates that the page failed to load. This can happen, for instance,
/// if DNS is unable to resolve the hostname.
///
///
///
/// await webViewPrefab.WaitUntilInitialized();
/// webViewPrefab.WebView.PageLoadFailed += (sender, eventArgs) => {
/// Debug.Log("Page load failed");
/// };
///
///
event EventHandler PageLoadFailed;
///
/// Indicates that the page's title changed.
///
///
///
/// await webViewPrefab.WaitUntilInitialized();
/// webViewPrefab.WebView.TitleChanged += (sender, eventArgs) => {
/// Debug.Log("Page title changed: " + eventArgs.Value);
/// };
///
///
event EventHandler> TitleChanged;
///
/// Indicates that the URL of the webview changed, either
/// due to user interaction or JavaScript.
///
///
///
/// await webViewPrefab.WaitUntilInitialized();
/// webViewPrefab.WebView.UrlChanged += (sender, eventArgs) => {
/// Debug.Log("URL changed: " + eventArgs.Url);
/// };
///
///
///
event EventHandler UrlChanged;
///
/// Gets a value indicating whether the instance has been disposed via Dispose().
///
bool IsDisposed { get; }
///
/// Gets a value indicating whether the instance has been initialized via Init().
///
bool IsInitialized { get; }
///
/// Gets a list of JavaScript scripts that are automatically executed in every new page that is loaded.
///
///
/// This list is empty by default, but the application can add scripts. When used in conjunction
/// with 3D WebView's [message passing API](https://support.vuplex.com/articles/how-to-send-messages-from-javascript-to-c-sharp),
/// it's possible to modify the browser's behavior in significant ways, similar to creating browser extensions.
///
///
///
/// // Add a script that automatically hides all scrollbars.
/// await webViewPrefab.WaitUntilInitialized();
/// webViewPrefab.WebView.PageLoadScripts.Add(@"
/// var styleElement = document.createElement('style');
/// styleElement.innerText = 'body::-webkit-scrollbar { display: none; }';
/// document.head.appendChild(styleElement);
/// ");
///
///
///
/// JS-to-C# message passing
List PageLoadScripts { get; }
///
/// Gets the instance's plugin type.
///
///
///
/// await webViewPrefab.WaitUntilInitialized();
/// Debug.Log("Plugin type: " + webViewPrefab.WebView.PluginType);
///
///
WebPluginType PluginType { get; }
///
/// Gets the webview's size in pixels.
///
///
///
/// await webViewPrefab.WaitUntilInitialized();
/// Debug.Log("Size: " + webViewPrefab.WebView.Size);
///
///
///
///
Vector2Int Size { get; }
///
/// Gets the texture for the webview's web content, or `null` if running in
/// Native 2D Mode. In order to render the texture, the application must use
/// a Material created with CreateMaterial().
///
///
///
/// This texture is an "external texture" created with
/// Texture2D.CreateExternalTexture(). An undocumented characteristic
/// of external textures in Unity is that not all Texture2D methods work for them.
/// For example, Texture2D.GetRawTextureData() and ImageConversion.EncodeToPNG()
/// fail for external textures. To compensate, the IWebView interface includes
/// its own GetRawTextureData() and CaptureScreenshot() methods to replace them.
///
///
/// Another quirk of this texture is that Unity always reports its size as
/// 1300px × 1300px in the editor. In reality, 3D WebView resizes the
/// texture in native code to match the dimensions of the webview, but
/// Unity doesn't provide an API to notify the engine that an external texture's size
/// has changed. So, Unity always reports its size as the initial size that was
/// passed to Texture2D.CreateExternalTexture(), which in 3D WebView's case is
/// 1300px × 1300px.
///
///
///
///
/// await webViewPrefab.WaitUntilInitialized();
/// var material = webViewPrefab.WebView.CreateMaterial();
/// // Note: the material returned by CreateMaterial() already
/// // has its mainTexture set to IWebView.Texture, so setting
/// // it explicitly like this is really only needed if you are
/// // switching a material from one webview's texture to another.
/// material.mainTexture = webViewPrefab.WebView.Texture;
///
///
Texture2D Texture { get; }
///
/// Gets the current web page title.
///
///
///
/// // Get the page's title after it finishes loading.
/// await webViewPrefab.WaitUntilInitialized();
/// await webViewPrefab.WebView.WaitForNextPageLoadToFinish();
/// Debug.Log("Page title: " + webViewPrefab.WebView.Title);
///
///
///
string Title { get; }
///
/// Gets the current URL.
///
///
///
/// // Get the page's URL after it finishes loading.
/// await webViewPrefab.WaitUntilInitialized();
/// await webViewPrefab.WebView.WaitForNextPageLoadToFinish();
/// Debug.Log("Page URL: " + webViewPrefab.WebView.Url);
///
///
///
string Url { get; }
///
/// Checks whether the webview can go back with a call to GoBack().
///
///
/// var canGoBack = await webViewPrefab.CanGoBack();
///
///
Task CanGoBack();
///
/// Checks whether the webview can go forward with a call to GoForward().
///
///
/// var canGoForward = await webViewPrefab.CanGoForward();
///
///
Task CanGoForward();
///
/// Returns a PNG image of the content visible in the webview.
///
///
/// On iOS, screenshots do not include video content, which appears black.
///
///
///
/// // Get a screenshot and write it to a file.
/// var screenshotBytes = await webViewPrefab.WebView.CaptureScreenshot();
/// var filePath = Path.Combine(Application.peristentDataPath, "screenshot.png");
/// File.WriteAllBytes(filePath, screenshotBytes);
///
///
/// ImageConversion.LoadImage()
///
Task CaptureScreenshot();
///
/// Clicks at the given coordinates in pixels in the web page, dispatching both a mouse
/// down and a mouse up event.
///
///
///
/// // Click at (250px, 100px).
/// webViewPrefab.WebView.Click(250, 100);
///
/// // Click at (50px, 150px) and prevent stealing focus from another webview.
/// webViewPrefab.WebView.Click(50, 150, true);
///
///
void Click(int xInPixels, int yInPixels, bool preventStealingFocus = false);
///
/// Like Click(int, int, bool?), except it takes a normalized point instead of
/// pixel coordinates.
///
///
///
/// // Click in the exact center of the page.
/// webViewPrefab.WebView.Click(new Vector2(0.5f, 0.5f));
///
/// // Click in the upper right quadrant of the page
/// // and prevent stealing focus from another webview.
/// webViewPrefab.WebView.Click(new Vector2(0.75f, 0.25f), true);
///
///
void Click(Vector2 normalizedPoint, bool preventStealingFocus = false);
///
/// Copies the selected text to the clipboard.
///
///
/// webViewPrefab.WebView.Copy();
///
///
///
///
void Copy();
///
/// Creates a Material that can be used to display the webview.
/// The returned material already has the webview's Texture set as its mainTexture.
///
///
/// Note that WebViewPrefab and CanvasWebViewPrefab take care of material creation for you, so you only need
/// to call this method directly if you need to create an IWebView instance outside of a prefab with
/// Web.CreateWebView().
///
///
///
/// GetComponent<Renderer>().material = webView.CreateMaterial();
///
///
Material CreateMaterial();
///
/// Copies the selected text to the clipboard and removes it.
///
///
/// webViewPrefab.WebView.Cut();
///
///
///
///
void Cut();
///
/// Destroys the webview, releasing all of its resources.
///
///
/// If you're using a WebViewPrefab or CanvasWebViewPrefab, please call Destroy() on the prefab instead
/// of calling IWebView.Dispose(). Calling IWebView.Dispose() while the prefab is still using the webview
/// can cause issues.
///
void Dispose();
///
/// Executes the given JavaScript in the context of the page and returns the result.
///
///
/// In order to run JavaScript, a web page must first be loaded. You can use WaitForNextPageLoadToFinish() or the
/// LoadProgressChanged event to run JavaScript after a page loads.
///
///
///
/// await webViewPrefab.WaitUntilInitialized();
/// await webViewPrefab.WebView.WaitForNextPageLoadToFinish();
/// var headerText = await webViewPrefab.WebView.ExecuteJavaScript("document.getElementsByTagName('h1')[0].innerText");
/// Debug.Log("H1 text: " + headerText);
///
///
///
/// JS-to-C# message passing
Task ExecuteJavaScript(string javaScript);
///
/// Like the other version of ExecuteJavaScript(), except it uses a callback instead
/// of a Task to return the result. If you don't need the result from executing the JavaScript, you can
/// improve the method's efficiency by passing `null` as the callback argument.
///
void ExecuteJavaScript(string javaScript, Action callback);
///
/// A replacement for [Texture2D.GetRawTextureData()](https://docs.unity3d.com/ScriptReference/Texture2D.GetRawTextureData.html)
/// for IWebView.Texture.
///
///
/// Unity's Texture2D.GetRawTextureData() method currently does not work for textures created with
/// Texture2D.CreateExternalTexture(). So, this method serves as a replacement by providing
/// the equivalent functionality. You can load the bytes returned by this method into another
/// texture using [Texture2D.LoadRawTextureData()](https://docs.unity3d.com/ScriptReference/Texture2D.LoadRawTextureData.html).
/// Note that on iOS, the texture data excludes video content, which appears black.
///
///
///
/// var textureData = await webViewPrefab.WebView.GetRawTextureData();
/// var texture = new Texture2D(
/// webView.Size.x,
/// webView.Size.y,
/// TextureFormat.RGBA32,
/// false,
/// false
/// );
/// texture.LoadRawTextureData(textureData);
/// texture.Apply();
///
///
/// Texture2D.GetRawTextureData()
///
Task GetRawTextureData();
///
/// Navigates back to the previous page in the webview's history.
///
///
/// webViewPrefab.WebView.GoBack();
///
///
void GoBack();
///
/// Navigates forward to the next page in the webview's history.
///
///
/// webViewPrefab.WebView.GoForward();
///
///
void GoForward();
///
/// Asynchronously initializes the webview with the given the dimensions in pixels.
///
///
/// Note that you don't need to call this method if you're using one of the prefabs, like WebViewPrefab.
/// You only need to call Init() if you create an IWebView directly with Web.CreateWebView()].
/// Also, this method's signature was [updated in 3D WebView v4](https://support.vuplex.com/articles/v4-changes#init).
///
Task Init(int width, int height);
///
/// Loads the web page contained in the given HTML string.
///
///
///
///
///
///
/// Test Page
///
///
///
/// LoadHtml Example
///
///
/// "
/// );
/// ]]>
///
///
///
void LoadHtml(string html);
///
/// Loads the given URL. Supported URL schemes:
/// - `http://`, `https://` - loads a remote page over HTTP
/// - `streaming-assets://` - loads a local page from StreamingAssets
/// (equivalent to `"file://" + Application.streamingAssetsPath + path`)
/// - `file://` - some platforms support loading arbitrary file URLs
///
///
///
/// await webViewPrefab.WaitUntilInitialized();
/// webViewPrefab.WebView.LoadUrl("https://vuplex.com");
///
///
/// How to load local files
///
///
void LoadUrl(string url);
///
/// Like LoadUrl(string url), but also sends the given additional HTTP request headers
/// when loading the URL. The headers are sent for the initial page load request but are not sent
/// for requests for subsequent resources, like linked JavaScript or CSS files.
///
///
/// On Windows and macOS, this method cannot be used to set the Accept-Language header.
/// For more info, please see [this article](https://support.vuplex.com/articles/how-to-change-accept-language-header).
///
///
///
/// await webViewPrefab.WaitUntilInitialized();
/// webViewPrefab.WebView.LoadUrl("https://vuplex.com", new Dictionary<string, string> {
/// ["Authorization"] = "Basic YWxhZGRpbjpvcGVuc2VzYW1l",
/// ["Cookie"] = "foo=bar"
/// });
///
///
void LoadUrl(string url, Dictionary additionalHttpHeaders);
///
/// Returns a point in pixels for the given normalized point.
///
///
Vector2Int NormalizedToPoint(Vector2 normalizedPoint);
///
/// Pastes text from the clipboard.
///
///
/// webViewPrefab.WebView.Paste();
///
///
///
void Paste();
///
/// Returns a normalized point for the given x and y coordinates in pixels.
/// This can be used to create normalized points for APIs that accept them, like MovePointer().
///
///
///
/// var webView = webViewPrefab.WebView;
/// // Scroll to the right by 50 pixels at (100px, 1300px).
/// webView.Scroll(
/// webView.PointToNormalized(50, 0),
/// webView.PointToNormalized(100, 1300)
/// );
///
///
///
Vector2 PointToNormalized(int xInPixels, int yInPixels);
///
/// Posts a message that JavaScript within the webview can listen for
/// using `window.vuplex.addEventListener('message', function(message) {})`.
/// The provided data string is passed as the data property of the message object.
/// For more details, please see [this support article](https://support.vuplex.com/articles/how-to-send-messages-from-javascript-to-c-sharp).
///
///
///
/// await webViewPrefab.WebView.WaitUntilInitialized();
/// // Add some JavaScript to the page to receive the message.
/// webViewPrefab.WebView.PageLoadScripts(@"
/// window.vuplex.addEventListener('message', function(event) {
/// console.log('Message received from C#: ' + event.data);
/// });
/// ");
/// // When the page finishes loading, send a message from C# to JavaScript.
/// await webViewPrefab.WebView.WaitForNextPageLoadToFinish();
/// webViewPrefab.WebView.PostMessage("Hello from C#");
///
///
void PostMessage(string data);
///
/// Reloads the current page.
///
///
/// webViewPrefab.WebView.Reload();
///
void Reload();
///
/// Resizes the webview to the given dimensions in pixels.
///
///
/// If you're using WebViewPrefab, you should call WebViewPrefab.Resize() instead.
///
///
///
void Resize(int width, int height);
///
/// Scrolls the top-level document by the given delta in pixels.
/// This method works by calling window.scrollBy(), which works for simple web
/// pages but not for all pages. An alternative is to instead use Scroll(Vector2, Vector2)
/// to scroll at a specific location in the page.
///
///
///
/// // Scroll down by 50 pixels.
/// webViewPrefab.WebView.Scroll(0, 50);
///
/// // Scroll to the left by 20 pixels.
/// webViewPrefab.WebView.Scroll(-20, 0);
///
///
void Scroll(int scrollDeltaXInPixels, int scrollDeltaYInPixels);
///
/// Like Scroll(int, int), but accepts a normalized scroll delta instead of
/// values in pixels.
///
///
///
/// // Scroll down one quarter of the page.
/// webViewPrefab.WebView.Scroll(new Vector2(0, 0.25f));
///
///
void Scroll(Vector2 normalizedScrollDelta);
///
/// Scrolls by the given normalized scroll delta at the given normalized pointer position.
///
///
///
/// var webView = webViewPrefab.WebView;
/// // Scroll down by a quarter of the page in the center of the page
/// webView.Scroll(new Vector2(0, 0.25f), new Vector2(0.5f, 0.5f));
///
/// // Scroll to the right by 50 pixels at (100px, 1300px).
/// webView.Scroll(
/// webView.PointToNormalized(50, 0),
/// webView.PointToNormalized(100, 1300)
/// );
///
///
void Scroll(Vector2 normalizedScrollDelta, Vector2 normalizedPoint);
///
/// Selects all text, depending on the page's focused element.
///
///
/// webViewPrefab.WebView.SelectAll();
///
///
void SelectAll();
///
/// Dispatches the given keyboard key to the webview.
///
///
/// A key can either be a single character representing
/// a unicode character (e.g. "A", "b", "?") or a [JavaScript key value](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values)
/// (e.g. "ArrowUp", "Enter", "Backspace", "Delete").
///
///
///
/// // Type "Hi!" and then submit the Enter key.
/// webViewPrefab.WebView.SendKey("H");
/// webViewPrefab.WebView.SendKey("i");
/// webViewPrefab.WebView.SendKey("!");
/// webViewPrefab.WebView.SendKey("Enter");
///
///
///
void SendKey(string key);
///
/// Makes the webview take or relinquish focus.
///
///
/// webViewPrefab.WebView.SetFocused(true);
///
void SetFocused(bool focused);
///
/// Enables or disables the webview's ability to render to its texture.
/// By default, a webview renders web content to its texture, but you can
/// use this method to disable or re-enable rendering.
///
///
/// This method is ignored when running in [Native 2D Mode](https://support.vuplex.com/articles/native-2d-mode).
///
///
/// webViewPrefab.WebView.SetRenderingEnabled(false);
///
void SetRenderingEnabled(bool enabled);
///
/// Stops the current page load if one is in progress.
///
///
/// webViewPrefab.WebView.StopLoad();
///
void StopLoad();
///
/// Returns a task that completes when the next page load finishes loading, or
/// throws a PageLoadFailedException if the page load fails.
///
///
///
/// await webViewPrefab.WaitUntilInitialized();
/// await webViewPrefab.WebView.WaitForNextPageLoadToFinish();
/// Debug.Log("The web page finished loading.");
///
///
///
Task WaitForNextPageLoadToFinish();
///
/// Zooms into the currently loaded web content. Note that the zoom level gets reset when a new page is loaded.
///
///
/// On Windows and macOS, adjusting the zoom also affects other webviews viewing the same site,
/// similar to how tabs behave in a desktop browser.
///
///
///
/// // Zoom in after the page finishes loading.
/// await webViewPrefab.WaitUntilInitialized();
/// await webViewPrefab.WebView.WaitForNextPageLoadToFinish();
/// webViewPrefab.WebView.ZoomIn();
///
///
void ZoomIn();
///
/// Zooms back out after a previous call to ZoomIn(). Note that the zoom level gets reset when a new page is loaded.
///
///
/// On Windows and macOS, adjusting the zoom also affects other webviews viewing the same site,
/// similar to how tabs behave in a desktop browser.
///
///
///
/// // Zoom out after the page finishes loading.
/// await webViewPrefab.WaitUntilInitialized();
/// await webViewPrefab.WebView.WaitForNextPageLoadToFinish();
/// webViewPrefab.WebView.ZoomOut();
///
///
void ZoomOut();
#region Obsolete APIs
// Added in v1.0, deprecated in v3.13, removed in v4.0.
[Obsolete(ObsoletionMessages.Blur, true)]
void Blur();
// Added in v1.0, deprecated in v3.16, removed in v4.0.
[Obsolete(ObsoletionMessages.CanGoBack, true)]
void CanGoBack(Action callback);
// Added in v1.0, deprecated in v3.16, removed in v4.0.
[Obsolete(ObsoletionMessages.CanGoForward, true)]
void CanGoForward(Action callback);
// Added in v2.4, deprecated in v3.16, removed in v4.0.
[Obsolete(ObsoletionMessages.CaptureScreenshot, true)]
void CaptureScreenshot(Action callback);
[Obsolete(ObsoletionMessages.DisableViewUpdates, true)]
void DisableViewUpdates();
[Obsolete(ObsoletionMessages.EnableViewUpdates, true)]
void EnableViewUpdates();
// Added in v1.0, deprecated in v3.13, removed in v4.0.
[Obsolete(ObsoletionMessages.Focus, true)]
void Focus();
// Added in v2.6, deprecated in v3.16, removed in v4.0.
[Obsolete(ObsoletionMessages.GetRawTextureData, true)]
void GetRawTextureData(Action callback);
// Added in v1.0, deprecated in v4.0.
[Obsolete(ObsoletionMessages.HandleKeyboardInput)]
void HandleKeyboardInput(string key);
// Added in v1.0, removed in v4.0.
[Obsolete(ObsoletionMessages.Init, true)]
void Init(Texture2D texture, float width, float height);
// Added in v1.0, removed in v4.0.
[Obsolete(ObsoletionMessages.Init2, true)]
void Init(Texture2D texture, float width, float height, Texture2D videoTexture);
// Added in v1.0, removed in v4.0.
[Obsolete(ObsoletionMessages.Resolution, true)]
float Resolution { get; }
// Added in v1.0, removed in v4.0.
[Obsolete(ObsoletionMessages.SetResolution, true)]
void SetResolution(float pixelsPerUnityUnit);
// Deprecated in v4.0
[Obsolete(ObsoletionMessages.SizeInPixels)]
Vector2 SizeInPixels { get; }
// Added in v1.0, removed in v4.0.
[Obsolete(ObsoletionMessages.VideoRectChanged, true)]
event EventHandler> VideoRectChanged;
// Added in v1.0, removed in v4.0.
[Obsolete(ObsoletionMessages.VideoTexture, true)]
Texture2D VideoTexture { get; }
#endregion
}
static class ObsoletionMessages {
public const string Blur = "IWebView.Blur() has been removed. Please use SetFocused(false) instead: https://developer.vuplex.com/webview/IWebView#SetFocused";
public const string CanGoBack = "The callback-based CanGoBack(Action) version of this method has been removed. Please switch to the Task-based CanGoBack() version instead. If you prefer using a callback instead of awaiting the Task, you can still use a callback like this: CanGoBack().ContinueWith(result => {...})";
public const string CanGoForward = "The callback-based CanGoForward(Action) version of this method has been removed. Please switch to the Task-based CanGoForward() version instead. If you prefer using a callback instead of awaiting the Task, you can still use a callback like this: CanGoForward().ContinueWith(result => {...})";
public const string CaptureScreenshot = "The callback-based CaptureScreenshot(Action) version of this method has been removed. Please switch to the Task-based CaptureScreenshot() version instead. If you prefer using a callback instead of awaiting the Task, you can still use a callback like this: CaptureScreenshot().ContinueWith(result => {...})";
public const string DisableViewUpdates = "DisableViewUpdates() has been removed. Please use SetRenderingEnabled(false) instead: https://developer.vuplex.com/webview/IWebView#SetRenderingEnabled";
public const string EnableViewUpdates = "EnableViewUpdates() has been removed. Please use SetRenderingEnabled(true) instead: https://developer.vuplex.com/webview/IWebView#SetRenderingEnabled";
public const string Focus = "IWebView.Focus() has been removed. Please use SetFocused(false) instead: https://developer.vuplex.com/webview/IWebView#SetFocused";
public const string GetRawTextureData = "The callback-based GetRawTextureData(Action) version of this method has been removed. Please switch to the Task-based GetRawTextureData() version instead. If you prefer using a callback instead of awaiting the Task, you can still use a callback like this: GetRawTextureData().ContinueWith(result => {...})";
public const string HandleKeyboardInput = "IWebView.HandleKeyboardInput() has been renamed to IWebView.SendKey(). Please switch to SendKey().";
public const string Init = "IWebView.Init(Texture2D, float, float) has been removed in v4. Please switch to IWebView.Init(int, int) and await the Task it returns. For more details, please see this article: https://support.vuplex.com/articles/v4-changes#init";
public const string Init2 = "IWebView.Init(Texture2D, float, float, Texture2D) has been removed in v4. Please switch to IWebView.Init(int, int) and await the Task it returns. For more details, please see this article: https://support.vuplex.com/articles/v4-changes#init";
public const string Resolution = "IWebView.Resolution has been removed in v4. Please use WebViewPrefab.Resolution or CanvasWebViewPrefab.Resolution instead. For more details, please see this article: https://support.vuplex.com/articles/v4-changes#resolution";
public const string SetResolution = "IWebView.SetResolution() has been removed in v4. Please set the WebViewPrefab.Resolution or CanvasWebViewPrefab.Resolution property instead. For more details, please see this article: https://support.vuplex.com/articles/v4-changes#resolution";
public const string SizeInPixels = "IWebView.SizeInPixels is now deprecated. Please use IWebView.Size instead: https://developer.vuplex.com/webview/IWebView#Size";
public const string VideoRectChanged = "IWebView.VideoRectChanged has been removed. Please use IWithFallbackVideo.VideoRectChanged instead: https://developer.vuplex.com/webview/IWithFallbackVideo#VideoRectChanged";
public const string VideoTexture = "IWebView.VideoTexture has been removed. Please use IWithFallbackVideo.VideoTexture instead: https://developer.vuplex.com/webview/IWithFallbackVideo#VideoTexture";
}
}