diff options
Diffstat (limited to 'Client/Assets/Scripts/UniWebView/Script/Helper')
-rw-r--r-- | Client/Assets/Scripts/UniWebView/Script/Helper/UniWebViewHelper.cs | 91 | ||||
-rw-r--r-- | Client/Assets/Scripts/UniWebView/Script/Helper/UniWebViewHelper.cs.meta | 9 |
2 files changed, 100 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/UniWebView/Script/Helper/UniWebViewHelper.cs b/Client/Assets/Scripts/UniWebView/Script/Helper/UniWebViewHelper.cs new file mode 100644 index 00000000..17e810b1 --- /dev/null +++ b/Client/Assets/Scripts/UniWebView/Script/Helper/UniWebViewHelper.cs @@ -0,0 +1,91 @@ +using UnityEngine;
+
+/// <summary>
+/// Supply some helper utility method for UniWebView
+/// </summary>
+public class UniWebViewHelper{
+ /// <summary>
+ /// Get the height of the screen.
+ /// </summary>
+ /// <value>
+ /// The height of screen.
+ /// </value>
+ /// <description>
+ /// In iOS devices, it will always return the screen height in "point",
+ /// instead of "pixel". It would be useful to use this value to calculate webview size.
+ /// On other platforms, it will just return Unity's Screen.height.
+ /// For example, a portrait iPhone 5 will return 568 and a landscape one 320. You should
+ /// always use this value to do screen-size-based insets calculation.
+ /// </description>
+ public static int screenHeight {
+ get {
+#if UNITY_IOS && !UNITY_EDITOR
+ return UniWebViewPlugin.ScreenHeight();
+#else
+ return Screen.height;
+#endif
+ }
+ }
+
+ /// <summary>
+ /// Get the height of the screen.
+ /// </summary>
+ /// <value>
+ /// The height of screen.
+ /// </value>
+ /// <description>
+ /// In iOS devices, it will always return the screen width in "point",
+ /// instead of "pixel". It would be useful to use this value to calculate webview size.
+ /// On other platforms, it will just return Unity's Screen.height.
+ /// For example, a portrait iPhone 5 will return 320 and a landscape one 568. You should
+ /// always use this value to do screen-size-based insets calculation.
+ /// </description>
+ public static int screenWidth {
+ get {
+#if UNITY_IOS && !UNITY_EDITOR
+ return UniWebViewPlugin.ScreenWidth();
+#else
+ return Screen.width;
+#endif
+ }
+ }
+
+ /// <summary>
+ /// Get the screen scale. In iOS or OS X Editor, it could be 1, 2 or 3 now, depending on the type of your screen.
+ /// </summary>
+ /// <value>The screen scale.</value>
+ public static int screenScale {
+ get {
+#if UNITY_IOS || UNITY_EDITOR
+ return UniWebViewPlugin.ScreenScale();
+#else
+ return 1;
+#endif
+ }
+ }
+
+ /// <summary>
+ /// Get the local streaming asset path for a given file path related to the StreamingAssets folder.
+ /// </summary>
+ /// <description>
+ /// This method will help you to concat a URL string for a file under your StreamingAssets folder for different platforms.
+ /// </description>
+ /// <param name="path">The relative path to the Assets/StreamingAssets of your file.
+ /// For example, if you placed a html file under Assets/StreamingAssets/www/index.html, you should pass `www/demo.html` as parameter.
+ /// </param>
+ /// <returns>The path you could use as the url for the web view.</returns>
+ public static string streamingAssetURLForPath(string path)
+ {
+#if UNITY_EDITOR
+ return Application.streamingAssetsPath + "/" + path;
+#elif UNITY_IOS
+ return Application.streamingAssetsPath + "/" + path;
+#elif UNITY_ANDROID
+ return "file:///android_asset/" + path;
+#elif UNITY_WP8
+ return "Data/StreamingAssets/" + path;
+#else
+ return string.Empty;
+#endif
+ }
+}
diff --git a/Client/Assets/Scripts/UniWebView/Script/Helper/UniWebViewHelper.cs.meta b/Client/Assets/Scripts/UniWebView/Script/Helper/UniWebViewHelper.cs.meta new file mode 100644 index 00000000..33e5071d --- /dev/null +++ b/Client/Assets/Scripts/UniWebView/Script/Helper/UniWebViewHelper.cs.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2
+guid: 140fc92629361465289bcaf88e465b88
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
|