UniWebViewPlaceholder.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #if UNITY_EDITOR_WIN || UNITY_EDITOR_LINUX || (!UNITY_EDITOR_OSX && !UNITY_STANDALONE_OSX && !UNITY_IOS && !UNITY_ANDROID)
  2. using System;
  3. using UnityEngine;
  4. public class UniWebViewInterface {
  5. private static bool alreadyLoggedWarning = false;
  6. public static void SetLogLevel(int level) { CheckPlatform(); }
  7. public static void Init(string name, int x, int y, int width, int height) { CheckPlatform(); }
  8. public static void Destroy(string name) { CheckPlatform(); }
  9. public static void Load(string name, string url, bool skipEncoding, string readAccessURL) { CheckPlatform(); }
  10. public static void LoadHTMLString(string name, string html, string baseUrl, bool skipEncoding) { CheckPlatform(); }
  11. public static void Reload(string name) { CheckPlatform(); }
  12. public static void Stop(string name) { CheckPlatform(); }
  13. public static string GetUrl(string name) { CheckPlatform(); return ""; }
  14. public static void SetFrame(string name, int x, int y, int width, int height) { CheckPlatform(); }
  15. public static void SetPosition(string name, int x, int y) { CheckPlatform(); }
  16. public static void SetSize(string name, int width, int height) { CheckPlatform(); }
  17. public static void SetTransform(string name, float rotation, float scaleX, float scaleY) { CheckPlatform(); }
  18. public static void SetRoundCornerRadius(string name, float topLeft, float topRight, float bottomLeft, float bottomRight) { CheckPlatform(); }
  19. 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(); }
  20. public static bool Show(string name, bool fade, int edge, float duration, bool useAsync, string identifier) { CheckPlatform(); return false; }
  21. public static bool Hide(string name, bool fade, int edge, float duration, bool useAsync, string identifier) { CheckPlatform(); return false; }
  22. public static bool AnimateTo(string name, int x, int y, int width, int height, float duration, float delay, string identifier) { CheckPlatform(); return false; }
  23. public static void AddJavaScript(string name, string jsString, string identifier) { CheckPlatform(); }
  24. public static void EvaluateJavaScript(string name, string jsString, string identifier) { CheckPlatform(); }
  25. public static void ClosePopupWindow(string name, string popupId) { CheckPlatform(); }
  26. public static void GoBackPopupWindow(string name, string popupId) { CheckPlatform(); }
  27. public static void GoForwardPopupWindow(string name, string popupId) { CheckPlatform(); }
  28. public static void EvaluateJavaScriptInPopupWindow(string name, string popupId, string jsString, string identifier) { CheckPlatform(); }
  29. public static void CloseAllPopupWindows(string name) { CheckPlatform(); }
  30. public static void SetPopupPageEventEnabled(string name, bool enabled) { CheckPlatform(); }
  31. public static void AddUrlScheme(string name, string scheme) { CheckPlatform(); }
  32. public static void RemoveUrlScheme(string name, string scheme) { CheckPlatform(); }
  33. [Obsolete("AddSslExceptionDomain is deprecated. Use AddSslPinnedFingerprint instead.")]
  34. public static void AddSslExceptionDomain(string name, string domain) { CheckPlatform(); }
  35. [Obsolete("RemoveSslExceptionDomain is deprecated. Use RemoveSslPinnedFingerprint instead.")]
  36. public static void RemoveSslExceptionDomain(string name, string domain) { CheckPlatform(); }
  37. public static void AddSslPinnedFingerprint(string name, string domain, string fingerprint) { CheckPlatform(); }
  38. public static void RemoveSslPinnedFingerprint(string name, string domain, string fingerprint) { CheckPlatform(); }
  39. public static void SetHeaderField(string name, string key, string value) { CheckPlatform(); }
  40. public static void SetUserAgent(string name, string userAgent) { CheckPlatform(); }
  41. public static string GetUserAgent(string name) { CheckPlatform(); return ""; }
  42. public static void SetAllowAutoPlay(bool flag) { CheckPlatform(); }
  43. public static void SetAllowInlinePlay(bool flag) { CheckPlatform(); }
  44. public static void SetAllowJavaScriptOpenWindow(bool flag) { CheckPlatform(); }
  45. public static void SetForwardWebConsoleToNativeOutput(bool flag) { CheckPlatform(); }
  46. public static void SetAllowFileAccess(string name, bool flag) { CheckPlatform(); }
  47. public static void SetAllowFileAccessFromFileURLs(string name, bool flag) { CheckPlatform(); }
  48. public static void SetAllowUniversalAccessFromFileURLs(bool flag) { CheckPlatform(); }
  49. public static void SetJavaScriptEnabled(bool flag) { CheckPlatform(); }
  50. public static void SetLimitsNavigationsToAppBoundDomains(bool enabled) { CheckPlatform(); }
  51. public static void CleanCache(string name, bool includeStorage, string identifier) { CheckPlatform(); }
  52. public static void SetCacheMode(string name, int mode) { CheckPlatform(); }
  53. public static void ClearCookies() { CheckPlatform(); }
  54. public static void ClearCookies(string identifier) { CheckPlatform(); }
  55. public static void SetCookie(string url, string cookie, bool skipEncoding) { CheckPlatform(); }
  56. public static void SetCookie(string url, string cookie, bool skipEncoding, string identifier) { CheckPlatform(); }
  57. public static void RemoveCookies(string url, bool skipEncoding) { CheckPlatform(); }
  58. public static void RemoveCookies(string url, bool skipEncoding, string identifier) { CheckPlatform(); }
  59. public static void RemoveCookie(string url, string key, bool skipEncoding) { CheckPlatform(); }
  60. public static void RemoveCookie(string url, string key, bool skipEncoding, string identifier) { CheckPlatform(); }
  61. public static string GetCookie(string url, string key, bool skipEncoding) { CheckPlatform(); return ""; }
  62. public static void GetCookie(string url, string key, bool skipEncoding, string identifier) { CheckPlatform(); }
  63. public static void ClearHttpAuthUsernamePassword(string host, string realm) { CheckPlatform(); }
  64. public static void SetBackgroundColor(string name, float r, float g, float b, float a) { CheckPlatform(); }
  65. public static void SetWebViewAlpha(string name, float alpha) { CheckPlatform(); }
  66. public static float GetWebViewAlpha(string name) { CheckPlatform(); return 0.0f; }
  67. public static void SetShowSpinnerWhileLoading(string name, bool show) { CheckPlatform(); }
  68. public static void SetSpinnerText(string name, string text) { CheckPlatform(); }
  69. public static void SetAllowUserDismissSpinnerByGesture(string name, bool flag) { CheckPlatform(); }
  70. public static void ShowSpinner(string name) { CheckPlatform(); }
  71. public static void HideSpinner(string name) { CheckPlatform(); }
  72. public static bool CanGoBack(string name) { CheckPlatform(); return false; }
  73. public static bool CanGoForward(string name) { CheckPlatform(); return false; }
  74. public static void GoBack(string name) { CheckPlatform(); }
  75. public static void GoForward(string name) { CheckPlatform(); }
  76. public static void SetOpenLinksInExternalBrowser(string name, bool flag) { CheckPlatform(); }
  77. public static void SetHorizontalScrollBarEnabled(string name, bool enabled) { CheckPlatform(); }
  78. public static void SetVerticalScrollBarEnabled(string name, bool enabled) { CheckPlatform(); }
  79. public static void SetBouncesEnabled(string name, bool enabled) { CheckPlatform(); }
  80. public static void SetZoomEnabled(string name, bool enabled) { CheckPlatform(); }
  81. public static void SetShowToolbar(string name, bool show, bool animated, bool onTop, bool adjustInset) { CheckPlatform(); }
  82. public static void SetToolbarDoneButtonText(string name, string text) { CheckPlatform(); }
  83. public static void SetToolbarGoBackButtonText(string name, string text) { CheckPlatform(); }
  84. public static void SetToolbarGoForwardButtonText(string name, string text) { CheckPlatform(); }
  85. public static void SetToolbarTintColor(string name, float r, float g, float b) { CheckPlatform(); }
  86. public static void SetToolbarTextColor(string name, float r, float g, float b) { CheckPlatform(); }
  87. public static void SetUserInteractionEnabled(string name, bool enabled) { CheckPlatform(); }
  88. public static void SetTransparencyClickingThroughEnabled(string name, bool enabled) { CheckPlatform(); }
  89. public static void RefreshTransparencyClickingThroughLayout(string name) { CheckPlatform(); }
  90. public static void SetWebContentsDebuggingEnabled(bool enabled) { CheckPlatform(); }
  91. public static void SetAllowHTTPAuthPopUpWindow(string name, bool flag) { CheckPlatform(); }
  92. public static void SetAllowUserEditFileNameBeforeDownloading(string name, bool allowed) { CheckPlatform(); }
  93. public static void SetAutoDownloadEnabled(string name, bool enabled) { CheckPlatform(); }
  94. public static void Print(string name) { CheckPlatform(); }
  95. public static void CaptureSnapshot(string name, string filename) { CheckPlatform(); }
  96. public static void SetCalloutEnabled(string name, bool flag) { CheckPlatform(); }
  97. public static void SetSupportMultipleWindows(string name, bool enabled, bool allowJavaScriptOpening) { CheckPlatform(); }
  98. public static void SetDragInteractionEnabled(string name, bool flag) { CheckPlatform(); }
  99. public static void ScrollTo(string name, int x, int y, bool animated) { CheckPlatform(); }
  100. public static float NativeScreenWidth() { CheckPlatform(); return 0.0f; }
  101. public static float NativeScreenHeight() { CheckPlatform(); return 0.0f; }
  102. public static void SafeBrowsingInit(string name, string url) { CheckPlatform(); }
  103. public static void SafeBrowsingSetToolbarColor(string name, float r, float g, float b) { CheckPlatform(); }
  104. public static void SafeBrowsingShow(string name) { CheckPlatform(); }
  105. public static void SafeBrowsingInvalidate(string name) { CheckPlatform(); }
  106. public static bool IsAuthenticationIsSupported() { CheckPlatform(); return false; }
  107. public static void AuthenticationInit(string name, string url, string scheme) { CheckPlatform(); }
  108. public static void AuthenticationStart(string name) { CheckPlatform(); }
  109. public static void AuthenticationSetPrivateMode(string name, bool enabled) { CheckPlatform(); }
  110. public static bool SetEmbeddedToolbarConfig(string name, string json) { CheckPlatform(); return false; }
  111. public static void SetShowEmbeddedToolbar(string name, bool show) { CheckPlatform(); }
  112. public static void SetEmbeddedToolbarOnTop(string name, bool top) { CheckPlatform(); }
  113. public static void SetEmbeddedToolbarDoneButtonText(string name, string text) { CheckPlatform(); }
  114. public static void SetEmbeddedToolbarGoBackButtonText(string name, string text) { CheckPlatform(); }
  115. public static void SetEmbeddedToolbarGoForwardButtonText(string name, string text) { CheckPlatform(); }
  116. public static void SetEmbeddedToolbarTitleText(string name, string text) { CheckPlatform(); }
  117. public static void SetEmbeddedToolbarBackgroundColor(string name, Color color) { CheckPlatform(); }
  118. public static void SetEmbeddedToolbarButtonTextColor(string name, Color color) { CheckPlatform(); }
  119. public static void SetEmbeddedToolbarTitleTextColor(string name, Color color) { CheckPlatform(); }
  120. public static void SetEmeddedToolbarNavigationButtonsShow(string name, bool show) { CheckPlatform(); }
  121. public static void SetEmbeddedToolbarMaxHeight(string name, float height) { CheckPlatform(); }
  122. public static void StartSnapshotForRendering(string name, string identifier) { CheckPlatform(); }
  123. public static void StopSnapshotForRendering(string name) { CheckPlatform(); }
  124. public static byte[] GetRenderedData(string name, int x, int y, int width, int height) { CheckPlatform(); return null; }
  125. public static bool StartSnapshotTextureStream(string name, long streamId, int x, int y, int width, int height, float resolutionScale) { CheckPlatform(); return false; }
  126. public static bool StartSnapshotTextureStreamWithSyntheticFrames(string name, long streamId, int width, int height, int framePattern) { CheckPlatform(); return false; }
  127. public static void StopSnapshotTextureStream(string name, long streamId) { CheckPlatform(); }
  128. public static void TickSnapshotTextureStream(string name, long streamId) { CheckPlatform(); }
  129. public static void PumpSnapshotTextureStream(string name, long streamId) { CheckPlatform(); }
  130. public static bool IsSnapshotTextureStreamReady(string name, long streamId) { CheckPlatform(); return false; }
  131. public static int GetSnapshotTextureStreamWidth(string name, long streamId) { CheckPlatform(); return 0; }
  132. public static int GetSnapshotTextureStreamHeight(string name, long streamId) { CheckPlatform(); return 0; }
  133. public static long GetSnapshotTextureStreamFrameIndex(string name, long streamId) { CheckPlatform(); return 0; }
  134. public static IntPtr GetSnapshotTextureStreamTexturePointer(string name, long streamId) { CheckPlatform(); return IntPtr.Zero; }
  135. public static TextureFormat GetSnapshotTextureStreamTextureFormat() { CheckPlatform(); return TextureFormat.RGBA32; }
  136. public static long ConsumeSnapshotTextureStreamCpuFrame(string name, long streamId, IntPtr destination, int capacity) { CheckPlatform(); return -1; }
  137. public static bool SnapshotTextureStreamUsesCpuFallback() { CheckPlatform(); return false; }
  138. public static string CopyBackForwardList(string name) { CheckPlatform(); return ""; }
  139. public static void GoToIndexInBackForwardList(string listenerName, int index) { CheckPlatform(); }
  140. public static void CheckPlatform() {
  141. if (!alreadyLoggedWarning) {
  142. alreadyLoggedWarning = true;
  143. Debug.LogWarning("UniWebView only supports iOS/Android/macOS Editor. You current platform " + Application.platform + " is not supported.");
  144. }
  145. }
  146. }
  147. #endif