| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297 |
- //
- // UniWebViewInterface.cs
- // Created by Wang Wei(@onevcat) on 2017-04-11.
- //
- // This file is a part of UniWebView Project (https://uniwebview.com)
- // By purchasing the asset, you are allowed to use this code in as many as projects
- // you want, only if you publish the final products under the name of the same account
- // used for the purchase.
- //
- // This asset and all corresponding files (such as source code) are provided on an
- // “as is” basis, without warranty of any kind, express of implied, including but not
- // limited to the warranties of merchantability, fitness for a particular purpose, and
- // noninfringement. In no event shall the authors or copyright holders be liable for any
- // claim, damages or other liability, whether in action of contract, tort or otherwise,
- // arising from, out of or in connection with the software or the use of other dealing in the software.
- //
- #if (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_IOS) && !UNITY_EDITOR_WIN && !UNITY_EDITOR_LINUX
- using UnityEngine;
- using System;
- using System.Runtime.InteropServices;
- using AOT;
- using System.Reflection;
- using System.Text;
- using UnityEngine.Rendering;
- public class UniWebViewInterface {
-
- private const string StaticListenerName = "__UniWebViewGlobalListener";
- private const string GlobalChannelIdentifier = "__UniWebViewGlobalChannelIdentifier";
-
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- delegate void UnitySendMessageDelegate(IntPtr objectName, IntPtr methodName, IntPtr parameter);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- delegate IntPtr ChannelMethodDelegate(IntPtr namePtr, IntPtr methodPtr, IntPtr parameterPtr);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- delegate void ChannelMethodResultReleaseDelegate(IntPtr resultPtr);
- private const string DllLib =
- #if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
- "UniWebView";
- #else
- "__Internal";
- #endif
- static UniWebViewInterface() {
- ConnectMessageSender();
- RegisterChannel();
- // Prepare dispatcher instance. Some callbacks may come from non-UI threads. Use this dispatcher to
- // send any action to the Unity main thread.
- _ = UniWebViewMainThreadDispatcher.Instance;
- }
- // Keep strong managed references to the callbacks handed to native. Native holds these function
- // pointers for the whole app lifetime; without a rooted reference the marshalled thunk can be
- // garbage collected (notably under Mono in the macOS Editor), leaving native with a dangling
- // pointer that crashes on the next callback.
- private static readonly UnitySendMessageDelegate sendMessageDelegate = SendMessage;
- private static readonly ChannelMethodDelegate channelMethodDelegate = ChannelFunc;
- private static readonly ChannelMethodResultReleaseDelegate channelMethodResultReleaseDelegate = ReleaseChannelResult;
- private static bool correctPlatform =
- #if UNITY_EDITOR_OSX
- Application.platform == RuntimePlatform.OSXEditor ||
- Application.platform == RuntimePlatform.IPhonePlayer || // Support for Device Simulator package
- Application.platform == RuntimePlatform.Android; // Support for Device Simulator package
- #elif UNITY_STANDALONE_OSX
- Application.platform == RuntimePlatform.OSXPlayer;
- #else
- Application.platform == RuntimePlatform.IPhonePlayer;
- #endif
- [DllImport(DllLib)]
- private static extern void uv_connectMessageSender(
- [MarshalAs(UnmanagedType.FunctionPtr)] UnitySendMessageDelegate sendMessageDelegate
- );
- static void ConnectMessageSender() {
- UniWebViewLogger.Instance.Info("Connecting to native side message sender.");
- CheckPlatform();
- uv_connectMessageSender(sendMessageDelegate);
- }
- [MonoPInvokeCallback(typeof(UnitySendMessageDelegate))]
- private static void SendMessage(IntPtr namePtr, IntPtr methodPtr, IntPtr parameterPtr) {
- try {
- string name = Marshal.PtrToStringAuto(namePtr);
- string method = Marshal.PtrToStringAuto(methodPtr);
- string parameters = Marshal.PtrToStringAuto(parameterPtr);
- UniWebViewLogger.Instance.Verbose(
- "Received message sent from native. Name: " + name + " Method: " + method + " Params: " + parameters
- );
- if (name == StaticListenerName) {
- UniWebViewStaticListener.InvokeStaticMethod(method, parameters);
- } else {
- var listener = UniWebViewNativeListener.GetListener(name);
- if (listener != null) {
- // Check if the listener's host reference is still valid
- // This prevents crash when webView is destroyed but callbacks are still pending
- if (listener.webView == null && listener.safeBrowsing == null && listener.session == null) {
- UniWebViewLogger.Instance.Debug(
- "Ignored message for destroyed webView. Listener: " + name + " Method: " + method
- );
- return;
- }
-
- MethodInfo methodInfo = typeof(UniWebViewNativeListener).GetMethod(method);
- if (methodInfo != null) {
- try {
- methodInfo.Invoke(listener, new object[] { parameters });
- } catch (System.Exception e) {
- // Additional safety: Log and ignore exceptions from destroyed objects
- UniWebViewLogger.Instance.Critical(
- "Exception in SendMessage callback - Listener: " + name +
- " Method: " + method + " Error: " + e.Message
- );
- }
- }
- }
- }
- } catch (System.Exception e) {
- // Top-level safety net for any marshalling or other issues
- UniWebViewLogger.Instance.Critical(
- "Critical error in SendMessage: " + e.Message + "\nStackTrace: " + e.StackTrace
- );
- }
- }
- [DllImport(DllLib)]
- private static extern void uv_registerChannel(
- [MarshalAs(UnmanagedType.FunctionPtr)] ChannelMethodDelegate channel,
- [MarshalAs(UnmanagedType.FunctionPtr)] ChannelMethodResultReleaseDelegate release
- );
- public static void RegisterChannel() {
- UniWebViewLogger.Instance.Info("Connecting to native side method channel.");
- CheckPlatform();
- uv_registerChannel(channelMethodDelegate, channelMethodResultReleaseDelegate);
- }
- [MonoPInvokeCallback(typeof(ChannelMethodDelegate))]
- private static IntPtr ChannelFunc(IntPtr namePtr, IntPtr methodPtr, IntPtr parameterPtr) {
- // This runs as a native->managed callback. An exception must never escape here: crossing the
- // reverse-P/Invoke boundary aborts the process under IL2CPP. Catch everything and return null.
- try {
- string name = Marshal.PtrToStringAuto(namePtr);
- string method = Marshal.PtrToStringAuto(methodPtr);
- string parameters = Marshal.PtrToStringAuto(parameterPtr);
- string result;
- if (name == GlobalChannelIdentifier) {
- UniWebViewLogger.Instance.Verbose( () =>
- "Global channel method invoked. Method: " + method + " Params: " + parameters
- );
- result = UniWebViewStaticListener.InvokeStaticMethod(method, parameters);
- } else {
- UniWebViewLogger.Instance.Verbose(() => $"ChannelFunc invoked by native side. Name: {name} Method: {method} Params: {parameters}");
- result = UniWebViewChannelMethodManager.Instance.InvokeMethod(name, method, parameters);
- }
- return AllocateChannelResult(result);
- } catch (System.Exception e) {
- UniWebViewLogger.Instance.Critical(
- "Critical error in ChannelFunc: " + e.Message + "\nStackTrace: " + e.StackTrace
- );
- return IntPtr.Zero;
- }
- }
- private static IntPtr AllocateChannelResult(string value) {
- if (value == null) {
- return IntPtr.Zero;
- }
- byte[] bytes = Encoding.UTF8.GetBytes(value);
- IntPtr resultPtr = Marshal.AllocHGlobal(bytes.Length + 1);
- try {
- Marshal.Copy(bytes, 0, resultPtr, bytes.Length);
- Marshal.WriteByte(resultPtr, bytes.Length, 0);
- return resultPtr;
- } catch {
- Marshal.FreeHGlobal(resultPtr);
- throw;
- }
- }
- [MonoPInvokeCallback(typeof(ChannelMethodResultReleaseDelegate))]
- private static void ReleaseChannelResult(IntPtr resultPtr) {
- if (resultPtr != IntPtr.Zero) {
- Marshal.FreeHGlobal(resultPtr);
- }
- }
- [DllImport(DllLib)]
- private static extern void uv_setLogLevel(int level);
- public static void SetLogLevel(int level) {
- CheckPlatform();
- uv_setLogLevel(level);
- }
- [DllImport(DllLib)]
- private static extern void uv_init(string name, int x, int y, int width, int height);
- public static void Init(string name, int x, int y, int width, int height) {
- CheckPlatform();
- if (String.IsNullOrEmpty(name)) {
- return;
- }
- uv_init(name, x, y, width, height);
- }
- [DllImport(DllLib)]
- private static extern void uv_destroy(string name);
- public static void Destroy(string name) {
- CheckPlatform();
- uv_destroy(name);
- }
- [DllImport(DllLib)]
- private static extern void uv_load(string name, string url, bool skipEncoding, string readAccessURL);
- public static void Load(string name, string url, bool skipEncoding, string readAccessURL) {
- CheckPlatform();
- uv_load(name, url, skipEncoding, readAccessURL);
- }
- [DllImport(DllLib)]
- private static extern void uv_loadHTMLString(string name, string html, string baseUrl, bool skipEncoding);
- public static void LoadHTMLString(string name, string html, string baseUrl, bool skipEncoding) {
- CheckPlatform();
- uv_loadHTMLString(name, html, baseUrl, skipEncoding);
- }
- [DllImport(DllLib)]
- private static extern void uv_reload(string name);
- public static void Reload(string name) {
- CheckPlatform();
- uv_reload(name);
- }
- [DllImport(DllLib)]
- private static extern void uv_stop(string name);
- public static void Stop(string name) {
- CheckPlatform();
- uv_stop(name);
- }
- [DllImport(DllLib)]
- private static extern string uv_getUrl(string name);
- public static string GetUrl(string name) {
- CheckPlatform();
- return uv_getUrl(name);
- }
- [DllImport(DllLib)]
- private static extern void uv_setFrame(string name, int x, int y, int width, int height);
- public static void SetFrame(string name, int x, int y, int width, int height) {
- CheckPlatform();
- uv_setFrame(name, x, y, width, height);
- }
- [DllImport(DllLib)]
- private static extern void uv_setPosition(string name, int x, int y);
- public static void SetPosition(string name, int x, int y) {
- CheckPlatform();
- uv_setPosition(name, x, y);
- }
- [DllImport(DllLib)]
- private static extern void uv_setSize(string name, int width, int height);
- public static void SetSize(string name, int width, int height) {
- CheckPlatform();
- uv_setSize(name, width, height);
- }
-
- [DllImport(DllLib)]
- private static extern void uv_setTransform(string name, float rotation, float scaleX, float scaleY);
- public static void SetTransform(string name, float rotation, float scaleX, float scaleY) {
- CheckPlatform();
- uv_setTransform(name, rotation, scaleX, scaleY);
- }
- [DllImport(DllLib)]
- private static extern void uv_setRoundCornerRadius(string name, float topLeft, float topRight, float bottomLeft, float bottomRight);
- public static void SetRoundCornerRadius(string name, float topLeft, float topRight, float bottomLeft, float bottomRight) {
- CheckPlatform();
- uv_setRoundCornerRadius(name, topLeft, topRight, bottomLeft, bottomRight);
- }
- [DllImport(DllLib)]
- private static extern void uv_setShadow(
- string name,
- float red,
- float green,
- float blue,
- float alpha,
- float opacity,
- float radius,
- float offsetX,
- float offsetY,
- float spread
- );
- public static void SetShadow(
- string name,
- float red,
- float green,
- float blue,
- float alpha,
- float opacity,
- float radius,
- float offsetX,
- float offsetY,
- float spread
- ) {
- CheckPlatform();
- uv_setShadow(name, red, green, blue, alpha, opacity, radius, offsetX, offsetY, spread);
- }
- [DllImport(DllLib)]
- [return: MarshalAs(UnmanagedType.I1)]
- private static extern bool uv_show(string name, bool fade, int edge, float duration, string identifier);
- public static bool Show(string name, bool fade, int edge, float duration, bool useAsync, string identifier) {
- CheckPlatform();
- return uv_show(name, fade, edge, duration, identifier);
- }
- [DllImport(DllLib)]
- [return: MarshalAs(UnmanagedType.I1)]
- private static extern bool uv_hide(string name, bool fade, int edge, float duration, string identifier);
- public static bool Hide(string name, bool fade, int edge, float duration, bool useAsync, string identifier) {
- CheckPlatform();
- return uv_hide(name, fade, edge, duration, identifier);
- }
- [DllImport(DllLib)]
- [return: MarshalAs(UnmanagedType.I1)]
- private static extern bool uv_animateTo(
- string name, int x, int y, int width, int height, float duration, float delay, string identifier
- );
- public static bool AnimateTo(
- string name, int x, int y, int width, int height, float duration, float delay, string identifier)
- {
- CheckPlatform();
- return uv_animateTo(name, x, y, width, height, duration, delay, identifier);
- }
- [DllImport(DllLib)]
- private static extern void uv_addJavaScript(string name, string jsString, string identifier);
- public static void AddJavaScript(string name, string jsString, string identifier) {
- CheckPlatform();
- uv_addJavaScript(name, jsString, identifier);
- }
- [DllImport(DllLib)]
- private static extern void uv_evaluateJavaScript(string name, string jsString, string identifier);
- public static void EvaluateJavaScript(string name, string jsString, string identifier) {
- CheckPlatform();
- uv_evaluateJavaScript(name, jsString, identifier);
- }
- [DllImport(DllLib)]
- private static extern void uv_popupClose(string name, string popupId);
- public static void ClosePopupWindow(string name, string popupId) {
- CheckPlatform();
- uv_popupClose(name, popupId);
- }
- [DllImport(DllLib)]
- private static extern void uv_popupGoBack(string name, string popupId);
- public static void GoBackPopupWindow(string name, string popupId) {
- CheckPlatform();
- uv_popupGoBack(name, popupId);
- }
- [DllImport(DllLib)]
- private static extern void uv_popupGoForward(string name, string popupId);
- public static void GoForwardPopupWindow(string name, string popupId) {
- CheckPlatform();
- uv_popupGoForward(name, popupId);
- }
- [DllImport(DllLib)]
- private static extern void uv_popupEvaluateJavaScript(
- string name,
- string popupId,
- string jsString,
- string identifier
- );
- public static void EvaluateJavaScriptInPopupWindow(
- string name,
- string popupId,
- string jsString,
- string identifier
- ) {
- CheckPlatform();
- uv_popupEvaluateJavaScript(name, popupId, jsString, identifier);
- }
- [DllImport(DllLib)]
- private static extern void uv_popupCloseAll(string name);
- public static void CloseAllPopupWindows(string name) {
- CheckPlatform();
- uv_popupCloseAll(name);
- }
- [DllImport(DllLib)]
- private static extern void uv_popupSetPageEventEnabled(string name, bool enabled);
- public static void SetPopupPageEventEnabled(string name, bool enabled) {
- CheckPlatform();
- uv_popupSetPageEventEnabled(name, enabled);
- }
- [DllImport(DllLib)]
- private static extern void uv_addUrlScheme(string name, string scheme);
- public static void AddUrlScheme(string name, string scheme) {
- CheckPlatform();
- uv_addUrlScheme(name, scheme);
- }
- [DllImport(DllLib)]
- private static extern void uv_removeUrlScheme(string name, string scheme);
- public static void RemoveUrlScheme(string name, string scheme) {
- CheckPlatform();
- uv_removeUrlScheme(name, scheme);
- }
- [DllImport(DllLib)]
- private static extern void uv_addSslExceptionDomain(string name, string domain);
- [Obsolete("AddSslExceptionDomain is deprecated. Use AddSslPinnedFingerprint instead.")]
- public static void AddSslExceptionDomain(string name, string domain) {
- CheckPlatform();
- uv_addSslExceptionDomain(name, domain);
- }
- [DllImport(DllLib)]
- private static extern void uv_removeSslExceptionDomain(string name, string domain);
- [Obsolete("RemoveSslExceptionDomain is deprecated. Use RemoveSslPinnedFingerprint instead.")]
- public static void RemoveSslExceptionDomain(string name, string domain) {
- CheckPlatform();
- uv_removeSslExceptionDomain(name, domain);
- }
- [DllImport(DllLib)]
- private static extern void uv_addSslPinnedFingerprint(string name, string domain, string fingerprint);
- public static void AddSslPinnedFingerprint(string name, string domain, string fingerprint) {
- CheckPlatform();
- uv_addSslPinnedFingerprint(name, domain, fingerprint);
- }
- [DllImport(DllLib)]
- private static extern void uv_removeSslPinnedFingerprint(string name, string domain, string fingerprint);
- public static void RemoveSslPinnedFingerprint(string name, string domain, string fingerprint) {
- CheckPlatform();
- uv_removeSslPinnedFingerprint(name, domain, fingerprint);
- }
- [DllImport(DllLib)]
- private static extern void uv_setHeaderField(string name, string key, string value);
- public static void SetHeaderField(string name, string key, string value) {
- CheckPlatform();
- uv_setHeaderField(name, key, value);
- }
- [DllImport(DllLib)]
- private static extern void uv_setUserAgent(string name, string userAgent);
- public static void SetUserAgent(string name, string userAgent) {
- CheckPlatform();
- uv_setUserAgent(name, userAgent);
- }
- [DllImport(DllLib)]
- private static extern string uv_getUserAgent(string name);
- public static string GetUserAgent(string name) {
- CheckPlatform();
- return uv_getUserAgent(name);
- }
- [DllImport(DllLib)]
- private static extern void uv_setContentInsetAdjustmentBehavior(string name, int behavior);
- public static void SetContentInsetAdjustmentBehavior(
- string name, UniWebViewContentInsetAdjustmentBehavior behavior
- )
- {
- CheckPlatform();
- uv_setContentInsetAdjustmentBehavior(name, (int)behavior);
- }
- [DllImport(DllLib)]
- private static extern void uv_setAllowAutoPlay(bool flag);
- public static void SetAllowAutoPlay(bool flag) {
- CheckPlatform();
- uv_setAllowAutoPlay(flag);
- }
- [DllImport(DllLib)]
- private static extern void uv_setAllowInlinePlay(bool flag);
- public static void SetAllowInlinePlay(bool flag) {
- CheckPlatform();
- uv_setAllowInlinePlay(flag);
- }
- [DllImport(DllLib)]
- private static extern void uv_setAllowFileAccess(string name, bool flag);
- public static void SetAllowFileAccess(string name, bool flag) {
- CheckPlatform();
- uv_setAllowFileAccess(name, flag);
- }
- [DllImport(DllLib)]
- private static extern void uv_setAllowFileAccessFromFileURLs(string name, bool flag);
- public static void SetAllowFileAccessFromFileURLs(string name, bool flag) {
- CheckPlatform();
- uv_setAllowFileAccessFromFileURLs(name, flag);
- }
- [DllImport(DllLib)]
- private static extern void uv_setAllowUniversalAccessFromFileURLs(bool flag);
- public static void SetAllowUniversalAccessFromFileURLs(bool flag) {
- CheckPlatform();
- uv_setAllowUniversalAccessFromFileURLs(flag);
- }
-
- [DllImport(DllLib)]
- private static extern void uv_setForwardWebConsoleToNativeOutput(bool flag);
- public static void SetForwardWebConsoleToNativeOutput(bool flag) {
- CheckPlatform();
- uv_setForwardWebConsoleToNativeOutput(flag);
- }
- [DllImport(DllLib)]
- private static extern void uv_setAllowJavaScriptOpenWindow(bool flag);
- public static void SetAllowJavaScriptOpenWindow(bool flag) {
- CheckPlatform();
- uv_setAllowJavaScriptOpenWindow(flag);
- }
- [DllImport(DllLib)]
- private static extern void uv_setJavaScriptEnabled(bool flag);
- public static void SetJavaScriptEnabled(bool flag) {
- CheckPlatform();
- uv_setJavaScriptEnabled(flag);
- }
-
- [DllImport(DllLib)]
- private static extern void uv_setLimitsNavigationsToAppBoundDomains(bool flag);
- public static void SetLimitsNavigationsToAppBoundDomains(bool flag) {
- CheckPlatform();
- uv_setLimitsNavigationsToAppBoundDomains(flag);
- }
- [DllImport(DllLib)]
- private static extern void uv_cleanCache(string name, bool includeStorage, string identifier);
- public static void CleanCache(string name, bool includeStorage, string identifier) {
- CheckPlatform();
- uv_cleanCache(name, includeStorage, identifier);
- }
- [DllImport(DllLib)]
- private static extern void uv_setCacheMode(string name, int mode);
- public static void SetCacheMode(string name, int mode) {
- CheckPlatform();
- uv_setCacheMode(name, mode);
- }
- [DllImport(DllLib)]
- private static extern void uv_clearCookies();
- public static void ClearCookies() {
- CheckPlatform();
- uv_clearCookies();
- }
- [DllImport(DllLib)]
- private static extern void uv_clearCookiesAsync(string identifier);
- public static void ClearCookies(string identifier) {
- CheckPlatform();
- uv_clearCookiesAsync(identifier);
- }
- [DllImport(DllLib)]
- private static extern void uv_setCookie(string url, string cookie, bool skipEncoding);
- public static void SetCookie(string url, string cookie, bool skipEncoding) {
- CheckPlatform();
- uv_setCookie(url, cookie, skipEncoding);
- }
-
- [DllImport(DllLib)]
- private static extern void uv_setCookieAsync(string url, string cookie, bool skipEncoding, string identifier);
- public static void SetCookie(string url, string cookie, bool skipEncoding, string identifier) {
- CheckPlatform();
- uv_setCookieAsync(url, cookie, skipEncoding, identifier);
- }
- [DllImport(DllLib)]
- private static extern void uv_removeCookies(string url, bool skipEncoding);
- public static void RemoveCookies(string url, bool skipEncoding) {
- CheckPlatform();
- uv_removeCookies(url, skipEncoding);
- }
-
- [DllImport(DllLib)]
- private static extern void uv_removeCookiesAsync(string url, bool skipEncoding, string identifier);
- public static void RemoveCookies(string url, bool skipEncoding, string identifier) {
- CheckPlatform();
- uv_removeCookiesAsync(url, skipEncoding, identifier);
- }
- [DllImport(DllLib)]
- private static extern void uv_removeCookie(string url, string key, bool skipEncoding);
- public static void RemoveCookie(string url, string key, bool skipEncoding) {
- CheckPlatform();
- uv_removeCookie(url, key, skipEncoding);
- }
-
- [DllImport(DllLib)]
- private static extern void uv_removeCookieAsync(string url, string key, bool skipEncoding, string identifier);
- public static void RemoveCookie(string url, string key, bool skipEncoding, string identifier) {
- CheckPlatform();
- uv_removeCookieAsync(url, key, skipEncoding, identifier);
- }
- [DllImport(DllLib)]
- private static extern string uv_getCookie(string url, string key, bool skipEncoding);
- public static string GetCookie(string url, string key, bool skipEncoding) {
- CheckPlatform();
- return uv_getCookie(url, key, skipEncoding);
- }
-
- [DllImport(DllLib)]
- private static extern void uv_getCookieAsync(string url, string key, bool skipEncoding, string identifier);
- public static void GetCookie(string url, string key, bool skipEncoding, string identifier) {
- CheckPlatform();
- uv_getCookieAsync(url, key, skipEncoding, identifier);
- }
- [DllImport(DllLib)]
- private static extern void uv_clearHttpAuthUsernamePasswordHost(string host, string realm);
- public static void ClearHttpAuthUsernamePassword(string host, string realm) {
- CheckPlatform();
- uv_clearHttpAuthUsernamePasswordHost(host, realm);
- }
- [DllImport(DllLib)]
- private static extern void uv_setBackgroundColor(string name, float r, float g, float b, float a);
- public static void SetBackgroundColor(string name, float r, float g, float b, float a) {
- CheckPlatform();
- uv_setBackgroundColor(name, r, g, b, a);
- }
- [DllImport(DllLib)]
- private static extern void uv_setWebViewAlpha(string name, float alpha);
- public static void SetWebViewAlpha(string name, float alpha) {
- CheckPlatform();
- uv_setWebViewAlpha(name, alpha);
- }
- [DllImport(DllLib)]
- private static extern float uv_getWebViewAlpha(string name);
- public static float GetWebViewAlpha(string name) {
- CheckPlatform();
- return uv_getWebViewAlpha(name);
- }
- [DllImport(DllLib)]
- private static extern void uv_setShowSpinnerWhileLoading(string name, bool show);
- public static void SetShowSpinnerWhileLoading(string name, bool show) {
- CheckPlatform();
- uv_setShowSpinnerWhileLoading(name, show);
- }
- [DllImport(DllLib)]
- private static extern void uv_setSpinnerText(string name, string text);
- public static void SetSpinnerText(string name, string text) {
- CheckPlatform();
- uv_setSpinnerText(name, text);
- }
- [DllImport(DllLib)]
- private static extern void uv_setAllowUserDismissSpinnerByGesture(string name, bool flag);
- public static void SetAllowUserDismissSpinnerByGesture(string name, bool flag) {
- CheckPlatform();
- uv_setAllowUserDismissSpinnerByGesture(name, flag);
- }
- [DllImport(DllLib)]
- private static extern void uv_showSpinner(string name);
- public static void ShowSpinner(string name) {
- CheckPlatform();
- uv_showSpinner(name);
- }
- [DllImport(DllLib)]
- private static extern void uv_hideSpinner(string name);
- public static void HideSpinner(string name) {
- CheckPlatform();
- uv_hideSpinner(name);
- }
- [DllImport(DllLib)]
- [return: MarshalAs(UnmanagedType.I1)]
- private static extern bool uv_canGoBack(string name);
- public static bool CanGoBack(string name) {
- CheckPlatform();
- return uv_canGoBack(name);
- }
- [DllImport(DllLib)]
- [return: MarshalAs(UnmanagedType.I1)]
- private static extern bool uv_canGoForward(string name);
- public static bool CanGoForward(string name) {
- CheckPlatform();
- return uv_canGoForward(name);
- }
- [DllImport(DllLib)]
- private static extern void uv_goBack(string name);
- public static void GoBack(string name) {
- CheckPlatform();
- uv_goBack(name);
- }
- [DllImport(DllLib)]
- private static extern void uv_goForward(string name);
- public static void GoForward(string name) {
- CheckPlatform();
- uv_goForward(name);
- }
- [DllImport(DllLib)]
- private static extern void uv_setOpenLinksInExternalBrowser(string name, bool flag);
- public static void SetOpenLinksInExternalBrowser(string name, bool flag) {
- CheckPlatform();
- uv_setOpenLinksInExternalBrowser(name, flag);
- }
- [DllImport(DllLib)]
- private static extern void uv_setHorizontalScrollBarEnabled(string name, bool enabled);
- public static void SetHorizontalScrollBarEnabled(string name, bool enabled) {
- CheckPlatform();
- uv_setHorizontalScrollBarEnabled(name, enabled);
- }
- [DllImport(DllLib)]
- private static extern void uv_setVerticalScrollBarEnabled(string name, bool enabled);
- public static void SetVerticalScrollBarEnabled(string name, bool enabled) {
- CheckPlatform();
- uv_setVerticalScrollBarEnabled(name, enabled);
- }
- [DllImport(DllLib)]
- private static extern void uv_setBouncesEnabled(string name, bool enabled);
- public static void SetBouncesEnabled(string name, bool enabled) {
- CheckPlatform();
- uv_setBouncesEnabled(name, enabled);
- }
- [DllImport(DllLib)]
- private static extern void uv_setZoomEnabled(string name, bool enabled);
- public static void SetZoomEnabled(string name, bool enabled) {
- CheckPlatform();
- uv_setZoomEnabled(name, enabled);
- }
- [DllImport(DllLib)]
- private static extern void uv_setWindowUserResizeEnabled(string name, bool enabled);
- public static void SetWindowUserResizeEnabled(string name, bool enabled) {
- CheckPlatform();
- uv_setWindowUserResizeEnabled(name, enabled);
- }
- [DllImport(DllLib)]
- private static extern void uv_setUserInteractionEnabled(string name, bool enabled);
- public static void SetUserInteractionEnabled(string name, bool enabled) {
- CheckPlatform();
- uv_setUserInteractionEnabled(name, enabled);
- }
- [DllImport(DllLib)]
- private static extern void uv_setTransparencyClickingThroughEnabled(string name, bool enabled);
- public static void SetTransparencyClickingThroughEnabled(string name, bool enabled) {
- CheckPlatform();
- uv_setTransparencyClickingThroughEnabled(name, enabled);
- }
- [DllImport(DllLib)]
- private static extern void uv_refreshTransparencyClickingThroughLayout(string name);
- public static void RefreshTransparencyClickingThroughLayout(string name) {
- CheckPlatform();
- uv_refreshTransparencyClickingThroughLayout(name);
- }
- [DllImport(DllLib)]
- private static extern void uv_setWebContentsDebuggingEnabled(bool enabled);
- public static void SetWebContentsDebuggingEnabled(bool enabled) {
- CheckPlatform();
- uv_setWebContentsDebuggingEnabled(enabled);
- }
- [DllImport(DllLib)]
- private static extern void uv_setAllowBackForwardNavigationGestures(string name, bool flag);
- public static void SetAllowBackForwardNavigationGestures(string name, bool flag) {
- CheckPlatform();
- uv_setAllowBackForwardNavigationGestures(name, flag);
- }
- [DllImport(DllLib)]
- private static extern void uv_setAllowHTTPAuthPopUpWindow(string name, bool flag);
- public static void SetAllowHTTPAuthPopUpWindow(string name, bool flag) {
- CheckPlatform();
- uv_setAllowHTTPAuthPopUpWindow(name, flag);
- }
- [DllImport(DllLib)]
- private static extern void uv_print(string name);
- public static void Print(string name) {
- CheckPlatform();
- uv_print(name);
- }
- [DllImport(DllLib)]
- private static extern void uv_captureSnapshot(string name, string fileName);
- public static void CaptureSnapshot(string name, string fileName) {
- CheckPlatform();
- uv_captureSnapshot(name, fileName);
- }
- [DllImport(DllLib)]
- private static extern void uv_scrollTo(string name, int x, int y, bool animated);
- public static void ScrollTo(string name, int x, int y, bool animated) {
- CheckPlatform();
- uv_scrollTo(name, x, y, animated);
- }
- [DllImport(DllLib)]
- private static extern void uv_setCalloutEnabled(string name, bool flag);
- public static void SetCalloutEnabled(string name, bool flag) {
- CheckPlatform();
- uv_setCalloutEnabled(name, flag);
- }
- [DllImport(DllLib)]
- private static extern void uv_setSupportMultipleWindows(string name, bool enabled, bool allowJavaScriptOpening);
- public static void SetSupportMultipleWindows(string name, bool enabled, bool allowJavaScriptOpening) {
- CheckPlatform();
- uv_setSupportMultipleWindows(name, enabled, allowJavaScriptOpening);
- }
- [DllImport(DllLib)]
- private static extern void uv_setDragInteractionEnabled(string name, bool flag);
- public static void SetDragInteractionEnabled(string name, bool flag) {
- CheckPlatform();
- uv_setDragInteractionEnabled(name, flag);
- }
- [DllImport(DllLib)]
- private static extern float uv_nativeScreenWidth();
- public static float NativeScreenWidth() {
- #if UNITY_EDITOR_OSX
- return Screen.width;
- #else
- return uv_nativeScreenWidth();
- #endif
- }
- [DllImport(DllLib)]
- private static extern float uv_nativeScreenHeight();
- public static float NativeScreenHeight() {
- #if UNITY_EDITOR_OSX
- return Screen.height;
- #else
- return uv_nativeScreenHeight();
- #endif
- }
- [DllImport(DllLib)]
- private static extern void uv_addDownloadURL(string name, string urlString, int type);
- public static void AddDownloadURL(string name, string urlString, int type) {
- CheckPlatform();
- uv_addDownloadURL(name, urlString, type);
- }
- [DllImport(DllLib)]
- private static extern void uv_removeDownloadURL(string name, string urlString, int type);
- public static void RemoveDownloadURL(string name, string urlString, int type) {
- CheckPlatform();
- uv_removeDownloadURL(name, urlString, type);
- }
- [DllImport(DllLib)]
- private static extern void uv_addDownloadMIMEType(string name, string MIMEType, int type);
- public static void AddDownloadMIMEType(string name, string MIMEType, int type) {
- CheckPlatform();
- uv_addDownloadMIMEType(name, MIMEType, type);
- }
- [DllImport(DllLib)]
- private static extern void uv_removeDownloadMIMETypes(string name, string MIMEType, int type);
- public static void RemoveDownloadMIMETypes(string name, string MIMEType, int type) {
- CheckPlatform();
- uv_removeDownloadMIMETypes(name, MIMEType, type);
- }
-
- [DllImport(DllLib)]
- private static extern void uv_setAllowUserEditFileNameBeforeDownloading(string name, bool allowed);
- public static void SetAllowUserEditFileNameBeforeDownloading(string name, bool allowed) {
- CheckPlatform();
- uv_setAllowUserEditFileNameBeforeDownloading(name, allowed);
- }
- [DllImport(DllLib)]
- private static extern void uv_setAutoDownloadEnabled(string name, bool enabled);
- public static void SetAutoDownloadEnabled(string name, bool enabled) {
- CheckPlatform();
- uv_setAutoDownloadEnabled(name, enabled);
- }
-
- [DllImport(DllLib)]
- private static extern void uv_setAllowUserChooseActionAfterDownloading(string name, bool allowed);
- public static void SetAllowUserChooseActionAfterDownloading(string name, bool allowed) {
- CheckPlatform();
- uv_setAllowUserChooseActionAfterDownloading(name, allowed);
- }
- [DllImport(DllLib)]
- private static extern void uv_safeBrowsingInit(string name, string url);
- public static void SafeBrowsingInit(string name, string url) {
- CheckPlatform();
- if (String.IsNullOrEmpty(name)) {
- return;
- }
- uv_safeBrowsingInit(name, url);
- }
- [DllImport(DllLib)]
- private static extern void uv_safeBrowsingShow(string name);
- public static void SafeBrowsingShow(string name) {
- CheckPlatform();
- uv_safeBrowsingShow(name);
- }
- [DllImport(DllLib)]
- private static extern void uv_safeBrowsingSetToolbarColor(string name, float r, float g, float b);
- public static void SafeBrowsingSetToolbarColor(string name, float r, float g, float b) {
- CheckPlatform();
- uv_safeBrowsingSetToolbarColor(name, r, g, b);
- }
- [DllImport(DllLib)]
- private static extern void uv_safeBrowsingSetToolbarItemColor(string name, float r, float g, float b);
- public static void SafeBrowsingSetToolbarItemColor(string name, float r, float g, float b) {
- CheckPlatform();
- uv_safeBrowsingSetToolbarItemColor(name, r, g, b);
- }
- [DllImport(DllLib)]
- private static extern void uv_safeBrowsingDismiss(string name);
- public static void SafeBrowsingDismiss(string name) {
- CheckPlatform();
- uv_safeBrowsingDismiss(name);
- }
- [DllImport(DllLib)]
- private static extern void uv_safeBrowsingInvalidate(string name);
- public static void SafeBrowsingInvalidate(string name) {
- CheckPlatform();
- uv_safeBrowsingInvalidate(name);
- }
- [DllImport(DllLib)]
- [return: MarshalAs(UnmanagedType.I1)]
- private static extern bool uv_authenticationIsSupported();
- public static bool IsAuthenticationIsSupported() {
- CheckPlatform();
- return uv_authenticationIsSupported();
- }
- [DllImport(DllLib)]
- private static extern void uv_authenticationInit(string name, string url, string scheme);
- public static void AuthenticationInit(string name, string url, string scheme) {
- CheckPlatform();
- uv_authenticationInit(name, url, scheme);
- }
- [DllImport(DllLib)]
- private static extern void uv_authenticationStart(string name);
- public static void AuthenticationStart(string name) {
- CheckPlatform();
- uv_authenticationStart(name);
- }
-
- [DllImport(DllLib)]
- private static extern void uv_authenticationCancel(string name);
- public static void AuthenticationCancel(string name) {
- CheckPlatform();
- uv_authenticationCancel(name);
- }
- [DllImport(DllLib)]
- private static extern void uv_authenticationSetPrivateMode(string name, bool flag);
- public static void AuthenticationSetPrivateMode(string name, bool flag) {
- CheckPlatform();
- uv_authenticationSetPrivateMode(name, flag);
- }
- [DllImport(DllLib)]
- [return: MarshalAs(UnmanagedType.I1)]
- private static extern bool uv_setEmbeddedToolbarConfig(string name, string json);
- public static bool SetEmbeddedToolbarConfig(string name, string json) {
- CheckPlatform();
- return uv_setEmbeddedToolbarConfig(name, json);
- }
-
- [DllImport(DllLib)]
- private static extern void uv_setShowEmbeddedToolbar(string name, bool show);
- public static void SetShowEmbeddedToolbar(string name, bool show) {
- CheckPlatform();
- uv_setShowEmbeddedToolbar(name, show);
- }
-
- [DllImport(DllLib)]
- private static extern void uv_setEmbeddedToolbarOnTop(string name, bool top);
- public static void SetEmbeddedToolbarOnTop(string name, bool top) {
- CheckPlatform();
- uv_setEmbeddedToolbarOnTop(name, top);
- }
-
- [DllImport(DllLib)]
- private static extern void uv_setEmbeddedToolbarDoneButtonText(string name, string text);
- public static void SetEmbeddedToolbarDoneButtonText(string name, string text) {
- CheckPlatform();
- uv_setEmbeddedToolbarDoneButtonText(name, text);
- }
-
- [DllImport(DllLib)]
- private static extern void uv_setEmbeddedToolbarGoBackButtonText(string name, string text);
- public static void SetEmbeddedToolbarGoBackButtonText(string name, string text) {
- CheckPlatform();
- uv_setEmbeddedToolbarGoBackButtonText(name, text);
- }
-
- [DllImport(DllLib)]
- private static extern void uv_setEmbeddedToolbarGoForwardButtonText(string name, string text);
- public static void SetEmbeddedToolbarGoForwardButtonText(string name, string text) {
- CheckPlatform();
- uv_setEmbeddedToolbarGoForwardButtonText(name, text);
- }
-
- [DllImport(DllLib)]
- private static extern void uv_setEmbeddedToolbarTitleText(string name, string text);
- public static void SetEmbeddedToolbarTitleText(string name, string text) {
- CheckPlatform();
- uv_setEmbeddedToolbarTitleText(name, text);
- }
-
- [DllImport(DllLib)]
- private static extern void uv_setEmbeddedToolbarBackgroundColor(string name, float r, float g, float b, float a);
- public static void SetEmbeddedToolbarBackgroundColor(string name, Color color) {
- CheckPlatform();
- uv_setEmbeddedToolbarBackgroundColor(name, color.r, color.g, color.b, color.a);
- }
-
- [DllImport(DllLib)]
- private static extern void uv_setEmbeddedToolbarButtonTextColor(string name, float r, float g, float b, float a);
- public static void SetEmbeddedToolbarButtonTextColor(string name, Color color) {
- CheckPlatform();
- uv_setEmbeddedToolbarButtonTextColor(name, color.r, color.g, color.b, color.a);
- }
-
- [DllImport(DllLib)]
- private static extern void uv_setEmbeddedToolbarTitleTextColor(string name, float r, float g, float b, float a);
- public static void SetEmbeddedToolbarTitleTextColor(string name, Color color) {
- CheckPlatform();
- uv_setEmbeddedToolbarTitleTextColor(name, color.r, color.g, color.b, color.a);
- }
-
- [DllImport(DllLib)]
- private static extern void uv_setEmbeddedToolbarNavigationButtonsShow(string name, bool show);
- public static void SetEmeddedToolbarNavigationButtonsShow(string name, bool show) {
- CheckPlatform();
- uv_setEmbeddedToolbarNavigationButtonsShow(name, show);
- }
-
- [DllImport(DllLib)]
- private static extern void uv_setEmbeddedToolbarMaxHeight(string name, float height);
- public static void SetEmbeddedToolbarMaxHeight(string name, float height) {
- CheckPlatform();
- uv_setEmbeddedToolbarMaxHeight(name, height);
- }
- [DllImport(DllLib)]
- private static extern void uv_startSnapshotForRendering(string name, string identifier);
- public static void StartSnapshotForRendering(string name, string identifier) {
- CheckPlatform();
- uv_startSnapshotForRendering(name, identifier);
- }
- [DllImport(DllLib)]
- private static extern void uv_stopSnapshotForRendering(string name);
- public static void StopSnapshotForRendering(string name) {
- CheckPlatform();
- uv_stopSnapshotForRendering(name);
- }
-
- [DllImport(DllLib)]
- private static extern IntPtr uv_getRenderedData(string name, int x, int y, int width, int height, out int length);
- public static byte[] GetRenderedData(string name, int x, int y, int width, int height) {
- CheckPlatform();
- IntPtr dataPtr = uv_getRenderedData(name, x, y, width, height, out var length);
- if (dataPtr == IntPtr.Zero || length <= 0) {
- return null;
- }
- byte[] managedData = new byte[length];
- Marshal.Copy(dataPtr, managedData, 0, length);
- return managedData;
- }
- [DllImport(DllLib)]
- [return: MarshalAs(UnmanagedType.I1)]
- private static extern bool uv_startSnapshotTextureStream(string name, long streamId, int x, int y, int width, int height, float resolutionScale);
- public static bool StartSnapshotTextureStream(string name, long streamId, int x, int y, int width, int height, float resolutionScale) {
- CheckPlatform();
- if (!IsSnapshotTextureStreamGraphicsBackendSupported()) {
- UniWebViewLogger.Instance.Critical("Snapshot texture stream is unavailable. Cocoa currently supports Metal only.");
- return false;
- }
- return uv_startSnapshotTextureStream(name, streamId, x, y, width, height, resolutionScale);
- }
- [DllImport(DllLib)]
- [return: MarshalAs(UnmanagedType.I1)]
- private static extern bool uv_startSnapshotTextureStreamSynthetic(string name, long streamId, int width, int height, int framePattern);
- public static bool StartSnapshotTextureStreamWithSyntheticFrames(
- string name, long streamId, int width, int height, int framePattern
- ) {
- CheckPlatform();
- if (!IsSnapshotTextureStreamGraphicsBackendSupported()) {
- UniWebViewLogger.Instance.Critical("Snapshot texture stream is unavailable. Cocoa currently supports Metal only.");
- return false;
- }
- return uv_startSnapshotTextureStreamSynthetic(name, streamId, width, height, framePattern);
- }
- [DllImport(DllLib)]
- private static extern void uv_stopSnapshotTextureStream(string name, long streamId);
- public static void StopSnapshotTextureStream(string name, long streamId) {
- CheckPlatform();
- uv_stopSnapshotTextureStream(name, streamId);
- }
- [DllImport(DllLib)]
- private static extern void uv_tickSnapshotTextureStream(string name, long streamId);
- public static void TickSnapshotTextureStream(string name, long streamId) {
- CheckPlatform();
- uv_tickSnapshotTextureStream(name, streamId);
- }
- public static void PumpSnapshotTextureStream(string name, long streamId) {
- CheckPlatform();
- }
- [DllImport(DllLib)]
- [return: MarshalAs(UnmanagedType.I1)]
- private static extern bool uv_isSnapshotTextureStreamReady(string name, long streamId);
- public static bool IsSnapshotTextureStreamReady(string name, long streamId) {
- CheckPlatform();
- return uv_isSnapshotTextureStreamReady(name, streamId);
- }
- [DllImport(DllLib)]
- private static extern int uv_getSnapshotTextureStreamWidth(string name, long streamId);
- public static int GetSnapshotTextureStreamWidth(string name, long streamId) {
- CheckPlatform();
- return uv_getSnapshotTextureStreamWidth(name, streamId);
- }
- [DllImport(DllLib)]
- private static extern int uv_getSnapshotTextureStreamHeight(string name, long streamId);
- public static int GetSnapshotTextureStreamHeight(string name, long streamId) {
- CheckPlatform();
- return uv_getSnapshotTextureStreamHeight(name, streamId);
- }
- [DllImport(DllLib)]
- private static extern long uv_getSnapshotTextureStreamFrameIndex(string name, long streamId);
- public static long GetSnapshotTextureStreamFrameIndex(string name, long streamId) {
- CheckPlatform();
- return uv_getSnapshotTextureStreamFrameIndex(name, streamId);
- }
- [DllImport(DllLib)]
- private static extern IntPtr uv_getSnapshotTextureStreamTexturePointer(string name, long streamId);
- public static IntPtr GetSnapshotTextureStreamTexturePointer(string name, long streamId) {
- CheckPlatform();
- return uv_getSnapshotTextureStreamTexturePointer(name, streamId);
- }
- public static TextureFormat GetSnapshotTextureStreamTextureFormat() {
- CheckPlatform();
- return TextureFormat.BGRA32;
- }
- public static long ConsumeSnapshotTextureStreamCpuFrame(string name, long streamId, IntPtr destination, int capacity) {
- CheckPlatform();
- return -1;
- }
- public static bool SnapshotTextureStreamUsesCpuFallback() {
- CheckPlatform();
- return false;
- }
- private static bool IsSnapshotTextureStreamGraphicsBackendSupported() {
- return SystemInfo.graphicsDeviceType == GraphicsDeviceType.Metal;
- }
-
- [DllImport(DllLib)]
- private static extern string uv_copyBackForwardList(string name);
- public static string CopyBackForwardList(string name) {
- CheckPlatform();
- return uv_copyBackForwardList(name);
- }
-
- [DllImport(DllLib)]
- private static extern void uv_goToIndexInBackForwardList(string name, int index);
- public static void GoToIndexInBackForwardList(string listenerName, int index) {
- CheckPlatform();
- uv_goToIndexInBackForwardList(listenerName, index);
- }
- #region Deprecated
-
- [DllImport(DllLib)]
- private static extern void uv_setShowToolbar(string name, bool show, bool animated, bool onTop, bool adjustInset);
- public static void SetShowToolbar(string name, bool show, bool animated, bool onTop, bool adjustInset) {
- CheckPlatform();
- uv_setShowToolbar(name, show, animated, onTop, adjustInset);
- }
- [DllImport(DllLib)]
- private static extern void uv_setShowToolbarNavigationButtons(string name, bool show);
- public static void SetShowToolbarNavigationButtons(string name, bool show) {
- CheckPlatform();
- uv_setShowToolbarNavigationButtons(name, show);
- }
- [DllImport(DllLib)]
- private static extern void uv_setToolbarDoneButtonText(string name, string text);
- public static void SetToolbarDoneButtonText(string name, string text) {
- CheckPlatform();
- uv_setToolbarDoneButtonText(name, text);
- }
- [DllImport(DllLib)]
- private static extern void uv_setGoBackButtonText(string name, string text);
- public static void SetToolbarGoBackButtonText(string name, string text) {
- CheckPlatform();
- uv_setGoBackButtonText(name, text);
- }
- [DllImport(DllLib)]
- private static extern void uv_setGoForwardButtonText(string name, string text);
- public static void SetToolbarGoForwardButtonText(string name, string text) {
- CheckPlatform();
- uv_setGoForwardButtonText(name, text);
- }
- [DllImport(DllLib)]
- private static extern void uv_setToolbarTintColor(string name, float r, float g, float b);
- public static void SetToolbarTintColor(string name, float r, float g, float b) {
- CheckPlatform();
- uv_setToolbarTintColor(name, r, g, b);
- }
- [DllImport(DllLib)]
- private static extern void uv_setToolbarTextColor(string name, float r, float g, float b);
- public static void SetToolbarTextColor(string name, float r, float g, float b) {
- CheckPlatform();
- uv_setToolbarTextColor(name, r, g, b);
- }
-
- #endregion
- public static void CheckPlatform() {
- if (!correctPlatform) {
- throw new System.InvalidOperationException(
- "Method can only be performed on correct platform. Current: " + Application.platform
- );
- }
- }
- }
- #endif
|