| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295 |
- //
- // 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";
-
- 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;
- }
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- delegate void UnitySendMessageDelegate(IntPtr objectName, IntPtr methodName, IntPtr parameter);
- // 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 const string DllLib =
- #if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
- "UniWebView";
- #else
- "__Internal";
- #endif
- 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
- );
- }
- }
-
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- delegate IntPtr ChannelMethodDelegate(IntPtr namePtr, IntPtr methodPtr, IntPtr parameterPtr);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- delegate void ChannelMethodResultReleaseDelegate(IntPtr resultPtr);
- [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
|