diff --git a/Assets/Editor/UniWebView.meta b/Assets/Editor/UniWebView.meta new file mode 100644 index 00000000..bce32a6b --- /dev/null +++ b/Assets/Editor/UniWebView.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cbfad999c612c244f9a6c609a97122ca +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor/UniWebView/settings.asset b/Assets/Editor/UniWebView/settings.asset new file mode 100644 index 00000000..d379f506 --- /dev/null +++ b/Assets/Editor/UniWebView/settings.asset @@ -0,0 +1,20 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a403a09e241a0480a957591ea60fb785, type: 3} + m_Name: settings + m_EditorClassIdentifier: + usesCleartextTraffic: 1 + writeExternalStorage: 0 + accessFineLocation: 0 + addsKotlin: 1 + addsAndroidBrowser: 1 + enableJetifier: 1 diff --git a/Assets/Editor/UniWebView/settings.asset.meta b/Assets/Editor/UniWebView/settings.asset.meta new file mode 100644 index 00000000..d2e1656c --- /dev/null +++ b/Assets/Editor/UniWebView/settings.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 580a44b4404956543a86c106381eae18 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Android/UniWebView.aar b/Assets/Plugins/Android/UniWebView.aar new file mode 100644 index 00000000..b1f159b3 Binary files /dev/null and b/Assets/Plugins/Android/UniWebView.aar differ diff --git a/Assets/Plugins/Android/UniWebView.aar.meta b/Assets/Plugins/Android/UniWebView.aar.meta new file mode 100644 index 00000000..2e731a42 --- /dev/null +++ b/Assets/Plugins/Android/UniWebView.aar.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: a70633e155d144f5da10d40c35d9c832 +timeCreated: 1528980533 +licenseType: Store +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + Android: Android + second: + enabled: 1 + settings: {} + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Android/mainTemplate.gradle b/Assets/Plugins/Android/mainTemplate.gradle index 5f5626cf..974558f2 100644 --- a/Assets/Plugins/Android/mainTemplate.gradle +++ b/Assets/Plugins/Android/mainTemplate.gradle @@ -8,6 +8,8 @@ dependencies { implementation files ("libs/unity-classes.jar") implementation files ("libs/unityandroidbluetoothlelib.jar") implementation files ('libs/PowerFunAndroidPlugin-release.aar') + implementation files ('libs/UniWebView.aar') + implementation ('com.mapbox.maps:android:10.2.0-beta.1'){ exclude group: 'group_name', module: 'module_name' } diff --git a/Assets/Plugins/UniWebView.bundle.meta b/Assets/Plugins/UniWebView.bundle.meta new file mode 100644 index 00000000..ab52d6cf --- /dev/null +++ b/Assets/Plugins/UniWebView.bundle.meta @@ -0,0 +1,46 @@ +fileFormatVersion: 2 +guid: db3f23043d1754d4b9c96ddb5ab457c9 +folderAsset: yes +timeCreated: 1492395437 +licenseType: Store +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 1 + settings: + DefaultValueInitialized: true + data: + first: + Standalone: OSXIntel + second: + enabled: 1 + settings: {} + data: + first: + Standalone: OSXIntel64 + second: + enabled: 1 + settings: {} + data: + first: + Standalone: OSXUniversal + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/UniWebView.bundle/Contents.meta b/Assets/Plugins/UniWebView.bundle/Contents.meta new file mode 100644 index 00000000..a8b41105 --- /dev/null +++ b/Assets/Plugins/UniWebView.bundle/Contents.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 19150ffd969374afd9b181cd8c71f662 +folderAsset: yes +timeCreated: 1536156019 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/UniWebView.bundle/Contents/Info.plist b/Assets/Plugins/UniWebView.bundle/Contents/Info.plist new file mode 100644 index 00000000..05fc8457 --- /dev/null +++ b/Assets/Plugins/UniWebView.bundle/Contents/Info.plist @@ -0,0 +1,48 @@ + + + + + BuildMachineOSBuild + 20G224 + CFBundleDevelopmentRegion + en + CFBundleExecutable + UniWebView + CFBundleIdentifier + com.onevcat.UniWebViewMac + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + UniWebView + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSupportedPlatforms + + MacOSX + + CFBundleVersion + 1 + DTCompiler + com.apple.compilers.llvm.clang.1_0 + DTPlatformBuild + 13A1030d + DTPlatformName + macosx + DTPlatformVersion + 12.0 + DTSDKBuild + 21A344 + DTSDKName + macosx12.0 + DTXcode + 1310 + DTXcodeBuild + 13A1030d + LSMinimumSystemVersion + 10.10 + NSHumanReadableCopyright + Copyright © 2017年 OneV's Den. All rights reserved. + + diff --git a/Assets/Plugins/UniWebView.bundle/Contents/Info.plist.meta b/Assets/Plugins/UniWebView.bundle/Contents/Info.plist.meta new file mode 100644 index 00000000..8771f433 --- /dev/null +++ b/Assets/Plugins/UniWebView.bundle/Contents/Info.plist.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6ed4d1ad77ba246f0aa50cb883ca2973 +timeCreated: 1536156020 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/UniWebView.bundle/Contents/MacOS.meta b/Assets/Plugins/UniWebView.bundle/Contents/MacOS.meta new file mode 100644 index 00000000..8b587cb3 --- /dev/null +++ b/Assets/Plugins/UniWebView.bundle/Contents/MacOS.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 495312126946747a3b197461eaff9687 +folderAsset: yes +timeCreated: 1536156020 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/UniWebView.bundle/Contents/MacOS/UniWebView b/Assets/Plugins/UniWebView.bundle/Contents/MacOS/UniWebView new file mode 100644 index 00000000..06a2264f Binary files /dev/null and b/Assets/Plugins/UniWebView.bundle/Contents/MacOS/UniWebView differ diff --git a/Assets/Plugins/UniWebView.bundle/Contents/MacOS/UniWebView.meta b/Assets/Plugins/UniWebView.bundle/Contents/MacOS/UniWebView.meta new file mode 100644 index 00000000..b0fd7a78 --- /dev/null +++ b/Assets/Plugins/UniWebView.bundle/Contents/MacOS/UniWebView.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0168f4971f50d488e959c40d05b94c59 +timeCreated: 1536156020 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/UniWebView.bundle/Contents/_CodeSignature.meta b/Assets/Plugins/UniWebView.bundle/Contents/_CodeSignature.meta new file mode 100644 index 00000000..78ce13a6 --- /dev/null +++ b/Assets/Plugins/UniWebView.bundle/Contents/_CodeSignature.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 80fcb824c01d44613803213f4b1ed096 +folderAsset: yes +timeCreated: 1536156020 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/UniWebView.bundle/Contents/_CodeSignature/CodeResources b/Assets/Plugins/UniWebView.bundle/Contents/_CodeSignature/CodeResources new file mode 100644 index 00000000..d5d0fd74 --- /dev/null +++ b/Assets/Plugins/UniWebView.bundle/Contents/_CodeSignature/CodeResources @@ -0,0 +1,115 @@ + + + + + files + + files2 + + rules + + ^Resources/ + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^version.plist$ + + + rules2 + + .*\.dSYM($|/) + + weight + 11 + + ^(.*/)?\.DS_Store$ + + omit + + weight + 2000 + + ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ + + nested + + weight + 10 + + ^.* + + ^Info\.plist$ + + omit + + weight + 20 + + ^PkgInfo$ + + omit + + weight + 20 + + ^Resources/ + + weight + 20 + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^[^/]+$ + + nested + + weight + 10 + + ^embedded\.provisionprofile$ + + weight + 20 + + ^version\.plist$ + + weight + 20 + + + + diff --git a/Assets/Plugins/UniWebView.bundle/Contents/_CodeSignature/CodeResources.meta b/Assets/Plugins/UniWebView.bundle/Contents/_CodeSignature/CodeResources.meta new file mode 100644 index 00000000..801a2282 --- /dev/null +++ b/Assets/Plugins/UniWebView.bundle/Contents/_CodeSignature/CodeResources.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f0a1c562a4f234a5c80db8830befc067 +timeCreated: 1536156020 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/iOS/libUniWebView.a b/Assets/Plugins/iOS/libUniWebView.a new file mode 100644 index 00000000..fa838b5d Binary files /dev/null and b/Assets/Plugins/iOS/libUniWebView.a differ diff --git a/Assets/Plugins/iOS/libUniWebView.a.meta b/Assets/Plugins/iOS/libUniWebView.a.meta new file mode 100644 index 00000000..3331e8ed --- /dev/null +++ b/Assets/Plugins/iOS/libUniWebView.a.meta @@ -0,0 +1,123 @@ +fileFormatVersion: 2 +guid: 060e1768692e941c2aa0f7c9f9f10e32 +timeCreated: 1493127399 +licenseType: Store +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 0 + data: + first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + data: + first: + '': data + second: + enabled: 0 + settings: {} + data: + first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + data: + first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + data: + first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + data: + first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + iPhone: iOS + second: + enabled: 1 + settings: + CompileFlags: + FrameworkDependencies: WebKit; + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/Test.unity b/Assets/Scenes/Test.unity index 021597e5..fd45ab9b 100644 --- a/Assets/Scenes/Test.unity +++ b/Assets/Scenes/Test.unity @@ -121,183 +121,6 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} ---- !u!224 &81998432 stripped -RectTransform: - m_CorrespondingSourceObject: {fileID: 3342506722007875057, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - m_PrefabInstance: {fileID: 3342506722068615057} - m_PrefabAsset: {fileID: 0} ---- !u!21 &381452049 -Material: - serializedVersion: 6 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: RoundedCornersTextureMaterial(Clone) - m_Shader: {fileID: 4800000, guid: 0bd2ec5d73751e34a814274a454bec41, type: 3} - m_ShaderKeywords: - m_LightmapFlags: 4 - m_EnableInstancingVariants: 0 - m_DoubleSidedGI: 0 - m_CustomRenderQueue: -1 - stringTagMap: {} - disabledShaderPasses: [] - m_SavedProperties: - serializedVersion: 3 - m_TexEnvs: - - _BumpMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailAlbedoMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailMask: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailNormalMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _EmissionMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _MainTex: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _MetallicGlossMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _OcclusionMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _ParallaxMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - m_Floats: - - _BumpScale: 1 - - _ColorMask: 15 - - _Cutoff: 0.5 - - _DetailNormalMapScale: 1 - - _DstBlend: 0 - - _GlossMapScale: 1 - - _Glossiness: 0.5 - - _GlossyReflections: 1 - - _Height: 50 - - _Metallic: 0 - - _Mode: 0 - - _OcclusionStrength: 1 - - _Parallax: 0.02 - - _Radius: 15 - - _SmoothnessTextureChannel: 0 - - _SpecularHighlights: 1 - - _SrcBlend: 1 - - _Stencil: 0 - - _StencilComp: 8 - - _StencilOp: 0 - - _StencilReadMask: 255 - - _StencilWriteMask: 255 - - _UVSec: 0 - - _UseUIAlphaClip: 0 - - _Width: 50 - - _ZWrite: 1 - m_Colors: - - _Color: {r: 1, g: 1, b: 1, a: 1} - - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - - _WidthHeightRadius: {r: 26, g: 26, b: 26, a: 0} ---- !u!21 &393975162 -Material: - serializedVersion: 6 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: IndependentCornersMaterial(Clone) - m_Shader: {fileID: 4800000, guid: d3beb88e61f88ca4393acdefb005fa70, type: 3} - m_ShaderKeywords: - m_LightmapFlags: 4 - m_EnableInstancingVariants: 0 - m_DoubleSidedGI: 0 - m_CustomRenderQueue: -1 - stringTagMap: {} - disabledShaderPasses: [] - m_SavedProperties: - serializedVersion: 3 - m_TexEnvs: - - _BumpMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailAlbedoMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailMask: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailNormalMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _EmissionMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _MainTex: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _MetallicGlossMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _OcclusionMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _ParallaxMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - m_Floats: - - _BumpScale: 1 - - _ColorMask: 15 - - _Cutoff: 0.5 - - _DetailNormalMapScale: 1 - - _DstBlend: 0 - - _GlossMapScale: 1 - - _Glossiness: 0.5 - - _GlossyReflections: 1 - - _Metallic: 0 - - _Mode: 0 - - _OcclusionStrength: 1 - - _Parallax: 0.02 - - _SmoothnessTextureChannel: 0 - - _SpecularHighlights: 1 - - _SrcBlend: 1 - - _Stencil: 0 - - _StencilComp: 8 - - _StencilOp: 0 - - _StencilReadMask: 255 - - _StencilWriteMask: 255 - - _UVSec: 0 - - _UseUIAlphaClip: 0 - - _ZWrite: 1 - m_Colors: - - _Color: {r: 1, g: 1, b: 1, a: 1} - - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - - _halfSize: {r: 289.5, g: 211, b: 0, a: 0} - - _r: {r: 20, g: 0, b: 0, a: 0} - - _rect2props: {r: 5.0000305, g: -5.000061, b: 346.8359, a: 353.90698} --- !u!1 &845512357 GameObject: m_ObjectHideFlags: 0 @@ -405,92 +228,6 @@ MonoBehaviour: m_EditorClassIdentifier: mMainPanel: {fileID: 0} Root: {fileID: 0} ---- !u!21 &911898334 -Material: - serializedVersion: 6 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: RoundedCornersTextureMaterial(Clone) - m_Shader: {fileID: 4800000, guid: 0bd2ec5d73751e34a814274a454bec41, type: 3} - m_ShaderKeywords: - m_LightmapFlags: 4 - m_EnableInstancingVariants: 0 - m_DoubleSidedGI: 0 - m_CustomRenderQueue: -1 - stringTagMap: {} - disabledShaderPasses: [] - m_SavedProperties: - serializedVersion: 3 - m_TexEnvs: - - _BumpMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailAlbedoMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailMask: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailNormalMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _EmissionMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _MainTex: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _MetallicGlossMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _OcclusionMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _ParallaxMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - m_Floats: - - _BumpScale: 1 - - _ColorMask: 15 - - _Cutoff: 0.5 - - _DetailNormalMapScale: 1 - - _DstBlend: 0 - - _GlossMapScale: 1 - - _Glossiness: 0.5 - - _GlossyReflections: 1 - - _Height: 50 - - _Metallic: 0 - - _Mode: 0 - - _OcclusionStrength: 1 - - _Parallax: 0.02 - - _Radius: 15 - - _SmoothnessTextureChannel: 0 - - _SpecularHighlights: 1 - - _SrcBlend: 1 - - _Stencil: 0 - - _StencilComp: 8 - - _StencilOp: 0 - - _StencilReadMask: 255 - - _StencilWriteMask: 255 - - _UVSec: 0 - - _UseUIAlphaClip: 0 - - _Width: 50 - - _ZWrite: 1 - m_Colors: - - _Color: {r: 1, g: 1, b: 1, a: 1} - - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - - _WidthHeightRadius: {r: 280, g: 44, b: 44, a: 0} --- !u!1 &1015587860 GameObject: m_ObjectHideFlags: 0 @@ -600,6 +337,119 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1174874344 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1174874345} + - component: {fileID: 1174874346} + - component: {fileID: 1174874348} + - component: {fileID: 1174874349} + - component: {fileID: 1174874347} + m_Layer: 5 + m_Name: Panel + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1174874345 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1174874344} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 2034365436} + m_Father: {fileID: 1678571401} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 700, y: 300} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &1174874346 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1174874344} + m_CullTransparentMesh: 0 +--- !u!114 &1174874347 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1174874344} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 598e18fb001004a81960f552978ecf4e, type: 3} + m_Name: + m_EditorClassIdentifier: + urlOnStart: http://www.baidu.com + showOnStart: 0 + fullScreen: 0 + useToolbar: 0 + toolbarPosition: 0 + frame: + serializedVersion: 2 + x: 0 + y: 0 + width: 844 + height: 390 + referenceRectTransform: {fileID: 1174874345} +--- !u!114 &1174874348 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1174874344} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 0.15294118, b: 0.25882354, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!114 &1174874349 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1174874344} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 87a02f5a9d8ce2e43b46b9bbbc2a04c4, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &1362042230 GameObject: m_ObjectHideFlags: 0 @@ -697,7 +547,7 @@ MonoBehaviour: m_UiScaleMode: 1 m_ReferencePixelsPerUnit: 100 m_ScaleFactor: 1 - m_ReferenceResolution: {x: 1600, y: 900} + m_ReferenceResolution: {x: 844, y: 390} m_ScreenMatchMode: 1 m_MatchWidthOrHeight: 0 m_PhysicalUnit: 3 @@ -736,8 +586,7 @@ RectTransform: m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 0, y: 0, z: 0} m_Children: - - {fileID: 3728196982312891800} - - {fileID: 81998432} + - {fileID: 1174874345} m_Father: {fileID: 0} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -754,261 +603,6 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1678571397} m_CullTransparentMesh: 0 ---- !u!21 &1782133642 -Material: - serializedVersion: 6 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: IndependentCornersMaterial(Clone) - m_Shader: {fileID: 4800000, guid: d3beb88e61f88ca4393acdefb005fa70, type: 3} - m_ShaderKeywords: - m_LightmapFlags: 4 - m_EnableInstancingVariants: 0 - m_DoubleSidedGI: 0 - m_CustomRenderQueue: -1 - stringTagMap: {} - disabledShaderPasses: [] - m_SavedProperties: - serializedVersion: 3 - m_TexEnvs: - - _BumpMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailAlbedoMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailMask: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailNormalMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _EmissionMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _MainTex: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _MetallicGlossMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _OcclusionMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _ParallaxMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - m_Floats: - - _BumpScale: 1 - - _ColorMask: 15 - - _Cutoff: 0.5 - - _DetailNormalMapScale: 1 - - _DstBlend: 0 - - _GlossMapScale: 1 - - _Glossiness: 0.5 - - _GlossyReflections: 1 - - _Metallic: 0 - - _Mode: 0 - - _OcclusionStrength: 1 - - _Parallax: 0.02 - - _SmoothnessTextureChannel: 0 - - _SpecularHighlights: 1 - - _SrcBlend: 1 - - _Stencil: 0 - - _StencilComp: 8 - - _StencilOp: 0 - - _StencilReadMask: 255 - - _StencilWriteMask: 255 - - _UVSec: 0 - - _UseUIAlphaClip: 0 - - _ZWrite: 1 - m_Colors: - - _Color: {r: 1, g: 1, b: 1, a: 1} - - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - - _halfSize: {r: 289.5, g: 211, b: 0, a: 0} - - _r: {r: 20, g: 0, b: 0, a: 0} - - _rect2props: {r: 5.0000305, g: -5.000061, b: 346.8359, a: 353.90698} ---- !u!21 &1792512907 -Material: - serializedVersion: 6 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: IndependentCornersMaterial(Clone) - m_Shader: {fileID: 4800000, guid: d3beb88e61f88ca4393acdefb005fa70, type: 3} - m_ShaderKeywords: - m_LightmapFlags: 4 - m_EnableInstancingVariants: 0 - m_DoubleSidedGI: 0 - m_CustomRenderQueue: -1 - stringTagMap: {} - disabledShaderPasses: [] - m_SavedProperties: - serializedVersion: 3 - m_TexEnvs: - - _BumpMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailAlbedoMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailMask: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailNormalMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _EmissionMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _MainTex: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _MetallicGlossMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _OcclusionMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _ParallaxMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - m_Floats: - - _BumpScale: 1 - - _ColorMask: 15 - - _Cutoff: 0.5 - - _DetailNormalMapScale: 1 - - _DstBlend: 0 - - _GlossMapScale: 1 - - _Glossiness: 0.5 - - _GlossyReflections: 1 - - _Metallic: 0 - - _Mode: 0 - - _OcclusionStrength: 1 - - _Parallax: 0.02 - - _SmoothnessTextureChannel: 0 - - _SpecularHighlights: 1 - - _SrcBlend: 1 - - _Stencil: 0 - - _StencilComp: 8 - - _StencilOp: 0 - - _StencilReadMask: 255 - - _StencilWriteMask: 255 - - _UVSec: 0 - - _UseUIAlphaClip: 0 - - _ZWrite: 1 - m_Colors: - - _Color: {r: 1, g: 1, b: 1, a: 1} - - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - - _halfSize: {r: 740, g: 388, b: 0, a: 0} - - _r: {r: 20, g: 20, b: 0, a: 0} - - _rect2props: {r: 0.000061035156, g: -10.000122, b: 790.5454, a: 790.5454} ---- !u!21 &1826292184 -Material: - serializedVersion: 6 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: IndependentCornersMaterial(Clone) - m_Shader: {fileID: 4800000, guid: d3beb88e61f88ca4393acdefb005fa70, type: 3} - m_ShaderKeywords: - m_LightmapFlags: 4 - m_EnableInstancingVariants: 0 - m_DoubleSidedGI: 0 - m_CustomRenderQueue: -1 - stringTagMap: {} - disabledShaderPasses: [] - m_SavedProperties: - serializedVersion: 3 - m_TexEnvs: - - _BumpMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailAlbedoMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailMask: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailNormalMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _EmissionMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _MainTex: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _MetallicGlossMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _OcclusionMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _ParallaxMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - m_Floats: - - _BumpScale: 1 - - _ColorMask: 15 - - _Cutoff: 0.5 - - _DetailNormalMapScale: 1 - - _DstBlend: 0 - - _GlossMapScale: 1 - - _Glossiness: 0.5 - - _GlossyReflections: 1 - - _Metallic: 0 - - _Mode: 0 - - _OcclusionStrength: 1 - - _Parallax: 0.02 - - _SmoothnessTextureChannel: 0 - - _SpecularHighlights: 1 - - _SrcBlend: 1 - - _Stencil: 0 - - _StencilComp: 8 - - _StencilOp: 0 - - _StencilReadMask: 255 - - _StencilWriteMask: 255 - - _UVSec: 0 - - _UseUIAlphaClip: 0 - - _ZWrite: 1 - m_Colors: - - _Color: {r: 1, g: 1, b: 1, a: 1} - - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - - _halfSize: {r: 740, g: 388, b: 0, a: 0} - - _r: {r: 20, g: 20, b: 0, a: 0} - - _rect2props: {r: 0.000061035156, g: -10.000122, b: 790.5454, a: 790.5454} --- !u!1 &1944211662 GameObject: m_ObjectHideFlags: 0 @@ -1092,567 +686,81 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 48.593002, y: -4.8190002, z: -6.4140005} ---- !u!1001 &3342506722068615057 -PrefabInstance: +--- !u!1 &2034365435 +GameObject: m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 1678571401} - m_Modifications: - - target: {fileID: 3342506722007875022, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - propertyPath: m_Name - value: Message - objectReference: {fileID: 0} - - target: {fileID: 3342506722007875056, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - propertyPath: m_Material - value: - objectReference: {fileID: 911898334} - - target: {fileID: 3342506722007875057, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - propertyPath: m_Pivot.x - value: 0.5 - objectReference: {fileID: 0} - - target: {fileID: 3342506722007875057, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - propertyPath: m_Pivot.y - value: 0.5 - objectReference: {fileID: 0} - - target: {fileID: 3342506722007875057, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - propertyPath: m_RootOrder - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 3342506722007875057, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - propertyPath: m_AnchorMax.x - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 3342506722007875057, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - propertyPath: m_AnchorMax.y - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 3342506722007875057, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - propertyPath: m_AnchorMin.x - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 3342506722007875057, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - propertyPath: m_AnchorMin.y - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 3342506722007875057, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - propertyPath: m_SizeDelta.x - value: 280 - objectReference: {fileID: 0} - - target: {fileID: 3342506722007875057, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - propertyPath: m_SizeDelta.y - value: 44 - objectReference: {fileID: 0} - - target: {fileID: 3342506722007875057, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - propertyPath: m_LocalPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3342506722007875057, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - propertyPath: m_LocalPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3342506722007875057, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3342506722007875057, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 3342506722007875057, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3342506722007875057, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3342506722007875057, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3342506722007875057, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - propertyPath: m_AnchoredPosition.x - value: -717 - objectReference: {fileID: 0} - - target: {fileID: 3342506722007875057, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - propertyPath: m_AnchoredPosition.y - value: -76 - objectReference: {fileID: 0} - - target: {fileID: 3342506722007875057, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3342506722007875057, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3342506722007875057, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3342506723879539847, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, - type: 3} - propertyPath: m_Material - value: - objectReference: {fileID: 381452049} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 10e54cf0bec9cbc4b94d1d40e437f87c, type: 3} ---- !u!224 &3728196982312891800 stripped -RectTransform: - m_CorrespondingSourceObject: {fileID: 9155624476384996310, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - m_PrefabInstance: {fileID: 5526612273759379022} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} ---- !u!1001 &5526612273759379022 -PrefabInstance: + serializedVersion: 6 + m_Component: + - component: {fileID: 2034365436} + - component: {fileID: 2034365438} + - component: {fileID: 2034365437} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2034365436 +RectTransform: m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 1678571401} - m_Modifications: - - target: {fileID: 380274271114832883, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 380274271114832883, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 380274271114832883, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5413612838137619147, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612271950846019, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612271950846019, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612271950846019, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612271950846019, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272056919338, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272056919338, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272056919338, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272056919338, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272056919338, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272165583874, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272278939589, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272278939589, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272278939589, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272278939589, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272284308391, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272284308391, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272284308391, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272284308391, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272284308391, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272308430552, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272308430552, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272308430552, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272308430552, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272308430552, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272378935001, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_SizeDelta.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272485525649, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272485525649, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272485525649, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272547339881, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272547339881, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272547339881, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272547339881, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_SizeDelta.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272547339881, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272547339881, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272623978842, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272623978842, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272623978842, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272623978842, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612272745412620, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_Material - value: - objectReference: {fileID: 1792512907} - - target: {fileID: 5526612272941488697, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612273137644949, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612273137644949, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612273137644949, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612273137644949, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612273367387532, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612273367387532, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612273367387532, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612273367387532, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612273750354142, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612273750354142, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612273750354142, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612273750354142, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612273772399091, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_Material - value: - objectReference: {fileID: 393975162} - - target: {fileID: 5526612273925040422, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612273925040422, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612273925040422, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612273925040422, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5526612273925040422, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9155624476384996305, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_Name - value: NewRouteDetailPanel - objectReference: {fileID: 0} - - target: {fileID: 9155624476384996310, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_Pivot.x - value: 0.5 - objectReference: {fileID: 0} - - target: {fileID: 9155624476384996310, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_Pivot.y - value: 0.5 - objectReference: {fileID: 0} - - target: {fileID: 9155624476384996310, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_RootOrder - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9155624476384996310, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMax.x - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 9155624476384996310, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMax.y - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 9155624476384996310, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMin.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9155624476384996310, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9155624476384996310, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9155624476384996310, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_SizeDelta.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9155624476384996310, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_LocalPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9155624476384996310, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_LocalPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9155624476384996310, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9155624476384996310, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 9155624476384996310, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9155624476384996310, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9155624476384996310, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9155624476384996310, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9155624476384996310, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9155624476384996310, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9155624476384996310, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9155624476384996310, guid: 5cd080a427081d74286771a7001f2ffa, - type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 5cd080a427081d74286771a7001f2ffa, type: 3} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2034365435} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1174874345} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 190} + m_SizeDelta: {x: 160, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &2034365437 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2034365435} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.94117653, g: 0.94117653, b: 0.94117653, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 20 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 2 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: New Text +--- !u!222 &2034365438 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2034365435} + m_CullTransparentMesh: 0 diff --git a/Assets/Scripts/App.cs b/Assets/Scripts/App.cs index b8c0d8a4..8a389621 100644 --- a/Assets/Scripts/App.cs +++ b/Assets/Scripts/App.cs @@ -18,7 +18,7 @@ public delegate void ChangeLanguageDelegate(); public static class App { - public static string Host = "http://192.168.0.101:5085/"; + public static string Host = "http://192.168.0.101:5084/"; public static string AppVersion = Application.version; diff --git a/Assets/UniWebView.meta b/Assets/UniWebView.meta new file mode 100644 index 00000000..772685ae --- /dev/null +++ b/Assets/UniWebView.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 92454175c62504ab5bf7128917b56362 +folderAsset: yes +timeCreated: 1490878496 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/CHANGELOG.md b/Assets/UniWebView/CHANGELOG.md new file mode 100644 index 00000000..b9fae950 --- /dev/null +++ b/Assets/UniWebView/CHANGELOG.md @@ -0,0 +1,1384 @@ +# Release Note + +### 4.10.3 (3 Dec, 2021) + +#### Fix + +* A crash when scrolling outside of the web view area when `SetTransparencyClickingThroughEnabled` is set to `true`. +* Now Android supports RTL languages layout. + +### 4.10.2 (25 Nov, 2021) + +#### Fix + +* Now UniWebView also supports NTLM authentication method. +* Uses the intent-based way to detect availability of SafeBrowsing. Now the `IsSafeBrowsingSupported` API would give back a more accurate result. +* Removes the requirement of Gradle plugin version of 4.0.1 or later. This fixes some Android build errors on earlier Unity versions which ships with an older Gradle Plugin. However, if you are using `UniWebViewSafeBrowsing` and setting the Target API Level to Android 11 (Level 30), you still need a newer version of Unity and follow the [related guide](https://docs.uniwebview.com/guide/safe-browsing.html) to add `queries` to the `AndroidManifest.xml` file. +* An issue that the toolbar on iOS can be clicked through to the Unity scene. + + +### 4.10.1 (11 Nov, 2021) + +#### Fix + +* An issue that `UniWebViewSafeBrowsing.IsSafeBrowsingSupported` may always return `false` wrongly when build against Android API 30 or above. + +### 4.10.0 (2 Oct, 2021) + +#### Add + +* Add option to support for using regular expression matching in `AddDownloadURL` or `AddDownloadMIMEType` methods. + +#### Fix + +* Now the `Load` method allows a `null` URL on Android instead of crash the game. +* The file downloading respects the SSL exception settings of the host web view now. +* The UniWebView message system now support URLs without authority part. Now, a URL like `myscheme:this_is_the_message?foo=bar` can be parsed without problem. + +### 4.9.0 (26 Jul, 2021) + +#### Add + +* New feature Transparency Clicking Through. Now you can use `SetTransparencyClickingThroughEnabled` and set the `BackgroundColor` of web view to a clear color to allow the user tap through the web view background. Those taps will be delivered to Unity scene. + +#### Fix + +* A potential issue that in some cases the `Hide` or `Show` method freeze the game for a few seconds. + +### 4.8.0 (19 Jul, 2021) + +#### Add + +* A method to disable the keyboard avoidance behavior on Android. It can prevent the web view layout changing when showing keyboard on Android. + +#### Fix + +* A gradle parser issue that ignores tab in a gradle node. This may lead some gradle build failing if a tab is used in the gradle file. +* Now the SSL error exception works properly even for resource on the allowed page. +* An issue which causes the video auto play not working on Android. + +### 4.7.0 (14 Jun, 2021) + +#### Add + +* A new method `SetTextZoom` on Android. It delegates setting to Android `WebSettings.setTextZoom` for the web view . +* A new method `SetDownloadEventForContextMenuEnabled` on Android. This allows the image saving action in context menu also triggers the `OnFileDownloadStarted` and `OnFileDownloadFinished` events. + +#### Fix + +* A potential issue that on some old Android devices, the `Show` and `Hide` methods do not return correct value for the animation starting state. + +### 4.6.1 (8 May, 2021) + +#### Fix + +* An issue that extension format of `accept` field is not recognized when uploading through the input file form on Android. It causes the file picker not shown up in some cases. + +### 4.6.0 (4 Apr, 2021) + +#### Add + +* Methods to remove cookies under a URL and with a certain cookie name. It allows you to remove some of the stored cookies instead of clearing them all. Check the `RemoveCookies` and `RemoveCooke` methods respectively. + +### 4.5.1 (12 Mar, 2021) + +#### Fix + +* Now file uploading from Android contains a more readable file name in its `Content-Disposition` field. +* An issue which causes external keyboard input is not valid while opening the web view on iOS. + +### 4.5.0 (17 Feb, 2021) + +#### Add + +* A new method to capture the current web view content and store it on a temporary folder on disk. Check `CaptureSnapshot` method and `OnCaptureSnapshotFinished` event for more. + +#### Fix + +* A potential issue that Safe Browsing crashes on certain devices without Chrome and Google Mobile Services (GMS) properly installed. + +### 4.4.0 (26 Jan, 2021) + +#### Add + +* Support download files in the general web view. Now, a download task will be triggered if the loading of resource cannot be rendered in place. See the [Downloading Files Guide](https://docs.uniwebview.com/guide/download-files.html) for more information. + +#### Fix + +* Now Jetifier is not required when Android exporting. If you need Jetifier for other third-party libraries, set it in UniWebView's setting panel. +* The `Hide` method now correctly hides the web view even when a full-screen view is being used on Android. + +### 4.3.1 (18 Dec, 2020) + +#### Fix + +* An issue that causes the app to crash on iOS 9 and 10 when closing the web view. + +### 4.3.0 (14 Dec, 2020) + +#### Add + +* A property to check whether the Safe Browsing Mode is supported on the device. Some Android devices may not have Chrome installed, so Safe Browsing Mode is not supported. Instead of ignoring the requests of opening the web page in Safe Browsing Mode, now UniWebView will open it in the installed system browser. Use `UniWebViewSafeBrowsing.IsSafeBrowsingSupported` to get availability. +* Add Assembly Definitions (`asmdef`) support. Now UniWebView will organize itself as an assembly. This should boost your compile-time in Unity Editor. + +#### Fix + +* Better support for multiple windows. The pop-up new web page window can pop another new window now. +* Now the script should compile when using Unity Editor even on Linux. +* A Gradle issue which causes error while exporting project when some certain customized Gradle templates are used. +* A potential problem that accessing to web page cookie might freeze the app in older iOS devices or systems. + +### 4.2.0 (17 Oct, 2020) + +#### Add + +* A method `SetAllowUniversalAccessFromFileURLs` to allow local file loading by AJAX from a local HTML page. This ignores CORS checking on iOS `WKWebView` when loading both the page and resource locally. +* Now you can enable the screen swipe gesture on iOS or macOS to perform back or forward navigation. Call `SetAllowBackForwardNavigationGestures` to allow it. +* Add opening and closing events for multiple window. Now you can receive `OnMultipleWindowOpened` and `OnMultipleWindowClosed` event when a new window is opened or closed respectively. + +#### Fix + +* Now the Safe Browsing on Android only requires "androidx.browser:browser" version 1.0.0. This solves some conflicting with other "old and bad-behaved" packages which not upgrading to the latest dependency. +* The JavaScript pop-up alert now has a better cancel button style. Also fixed the duplicated prompt text for input alert. +* An issue which causes wrong parsing for Gradle build file when a string is defined inside a non-node block. + +### 4.1.0 (26 Sep, 2020) + +#### Add + +* Add a method to dismiss the `UniWebViewSafeBrowsing` on iOS. To close an opened safe browsing component, call the `Dismiss` method. +* Build support for iOS 14 and Xcode 12. + +#### Fix + +* An issue that `BackgroundColor` property not working on Android. + +### 4.0.4 (1 Sep, 2020) + +#### Fix + +* An issue causes the web view does not show up until switching the app from background on some customized Android distribution. +* Now setting for "Accept" header will give a warning since iOS does not support customize this header field. + +### 4.0.3 (18 Aug, 2020) + +#### Fix + +* Fix an issue that causes keyboard overlaying not handled correctly on Android. + +### 4.0.2 (14 Aug, 2020) + +#### Fix + +* Android X browser dependency ('androidx.browser:browser') for UniWebView Android can now be disabled in the preference panel. Turn it off if other plugins are already adding it for you. + +### 4.0.1 (12 Aug, 2020) + +#### Fix + +* A issue that prevents the Gradle file being processed correctly if inline comments are used. +* Kotlin dependency for UniWebView Android can now be disabled in the preference panel. Turn it off if other plugins are already adding it for you. + +### 4.0.0 (1 Aug, 2020) + +::: danger +4.0.0 is a major update of UniWebView. Although most of APIs in UniWebView 4 are compatible with UniWebView 3 and it should be easy enough to migrate, there are still a few breaking changes. For migration from UniWebView 3 in detail, visit the [Migration Guide](https://docs.uniwebview.com/guide/migration-guide.html). To know the highlight of the version, check [this page](https://docs.uniwebview.com/guide/version-highlight.html) for more. +::: + +#### Add + +* **Safe Browsing Mode support.** Now UniWebView also contains a wrapper for [SFSafariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller) on iOS and [Custom Tabs](https://developers.google.com/web/android/custom-tabs) on Android. It allows you to browse web pages in a more browser-like level, including sharing cookies or credentials with the system browser. Check the [Safe Browsing guide](https://docs.uniwebview.com/guide/safe-browsing.html) for more information. +* **Customizable built-in toolbar on iOS.** Now you can set the bar background color, button text, and the text color in the toolbar. Check the [Built-in Toolbar](https://docs.uniwebview.com/guide/built-in-toolbar.html) guide for more information. +* **Add support for Unity 2020.1.** In the latest Unity version, it changes its way of handling native touch events. It may cause some functionality broken in UniWebView 3. UniWebView 4 uses itself in a new way to handle events to ensure working fine on all supported Unity versions. UniWebView 4 itself **supports from Unity 2018.3**. +* **New Post Build Processing system and Preference Panel.** They provide a better way to define the dependencies and help you modify the "AndroidManifest.xml" file without touch it directly. +* **Better permission model.** UniWebView now does not require the write external permission for uploading a photo from the gallery or camera to the web. It also adopts to permission models for Android 10. Other possible needed permission can be setup in the UniWebView Preference Panel. +* An `OnPageProgressChanged` event which will be raised every time the loading progress changes in the web view. + +#### Fix + +* Now the web view resizes itself when a soft keyboard is showing up and about to cover the text input fields on the page. It keeps the text input visible. +* UniWebView now always respects Unity setting of immersive mode on Android. The navigation bar will not jump out or flicker when showing the web view in an immersive mode. +* Audio resource can stop correctly when the web view is closed now. +* The alert pop-up and its text edit views for JavaScript confirm window or HTTP auth now have a better style and alignment. + +#### Deprecate + +* `SetImmersiveMode` is not needed anymore since the Unity setting is now always respected. This method will not do anything but give an error log instead. +* `OnKeyCodeReceived` will not be called anymore since UniWebView is not intercepting any native events. Try Unity's `Input.GetKeyUp` in `Update` to get key code events instead. + +### 3.18.1 (4 Jul, 2020) + +#### Fix + +* A potential issue that the Android keyboard is not shown when switching back from a full screen view on Android 9 or above. +* Now the Unity Editor support also allows displaying a web view when using the Device Simulator package. +* An issue on iOS which causes the toolbar buttons placed in wrong position when switching back to the game while the web view is showing. + +### 3.18.0 (14 May, 2020) + +#### Add + +* An API to disable the whole user interaction of the web view. Call `SetUserInteractionEnabled(false)` on the web view if you do not want users to tap or scroll the web view. +* Allow "Go Back" feature on a pop-up window if `SetSupportMultipleWindows` is set to `true`. + +#### Fix + +* An issue that the `OnPageFinished` event is not called on Android when loading an HTML string. + +### 3.17.0 (14 Apr, 2020) + +#### Add + +* A method to set the default font size on Android. This can help to reduce the influence of the user's display setting of the font scale. Use `SetDefaultFontSize` to give a more reasonable default font size based on the scale setting. +* Now the visibility of navigation buttons (Go Back and Go Forward) on iOS toolbar can be set from Unity by `SetShowToolbarNavigationButtons`. + +#### Fix + +* A layout issue that breaks web view size when switching back to foreground when an action sheet shown in some cases. +* The customized user agent string now also applies to the pop-up window when `SetSupportMultipleWindows` was called with `true`. +* An issue that causes the new window cannot be dismissed correctly by `window.close()` on Android. +* Now the text input views should be automatically scrolled up on Android when the soft keyboard displays and overlaps them. +* The `ReferenceRectTransform` can calculate the correct final size and position for a non-default resolution setting for screen now. + +### 3.16.0 (5 Feb, 2020) + +#### Add + +* Support for `target="_blank"` links. By default, UniWebView will open the destination URL in the same page even it is attributed by a `_blank` target. If you want to open it in a new page, call `SetSupportMultipleWindows` with `true` and it will create a new web view above the current one to load the new request. + +#### Fix + +* Improve SSL error handling logic for Android to prevent warnings from Google. + +### 3.15.2 (8 Jan, 2020) + +#### Fix + +* URLs with "#" should be loaded correctly in iOS even the `skipEncoding` is not set to `true` in `Load` method. +* The keyboard will be dismissed automatically when hiding the web view by calling `Hide` now. + +### 3.15.1 (18 Dec, 2019) + +#### Fix + +* Unity 2019.3 support. Fixed a problem which causes your app hanging and being killed at starting on iOS devices when building against Unity 2019.03 and without Xcode connected. +* A possible crash when uploading and converting data between file choosers. +* A potential issue that the Camera can be ignored when choosing images for uploading. + +### 3.15.0 (11 Dec, 2019) + +#### Add + +* A new method `ScrollTo` to scroll web view to a certain point. +* Basic localization support for Android. Now the UniWebView related UI elements are localized for the following locals: `en`, `zh`, `zh-rTW`, `ja`, `ko`, `fr`, `de`, `es`, `ru`, `vi`, `pt`, `da`, `it`, `nl`, `sv`. + +#### Fix + +* Solve an issue that HTTP status cannot be retrieved correctly due to page loading events order are not correct on some Android systems. +* Now the web view window will be pinned to top on macOS editor. This aligns the fact that the web view will always be the top-layer view on iOS and Android. + +### 3.14.0 (20 Nov, 2019) + +#### Add + +* New API `SetContentInsetAdjustmentBehavior` for setting the adjustment behavior which indicates how safe area insets. It is a wrapper for `contentInsetAdjustmentBehavior` on iOS. + +#### Fix + +* A crash when uploading a single picture taken by camera on some Android devices. +* Unescape JavaScript result from Android. This helps get correct value when using `GetHTMLContent`. + +### 3.13.2 (29 Aug, 2019) + +#### Fix + +* An unintended symbol link to deprecated UIWebView on iOS. This prevents the deprecation warning when submitting an app to the App Store. + +### 3.13.1 (17 Aug, 2019) + +#### Fix + +* Enabled app cache support for web view on Android. + +### 3.13.0 (11 Jun, 2019) + +::: warning +From 3.13.0, UniWebView supports from Unity 2017.3. This would help to reduce some legacy code and achieve more stable behaviors. +If you need to continue use UniWebView 3 on Unity 5.6, Unity 2017.1 or Unity 2017.2, please keep to use UniWebView 3.12.1 or earlier. +::: + +#### Add + +* Support on Android for uploading multiple files at the same time. + +#### Fix + +* The `RawMessage` of `UniWebViewMessage` is now not escaped any more. It will return exactly the original URL it receives. Meanwhile, the values in `Args` keep escaped as is. +* An issue on iPad that the customized "Done" button text might be truncated in some cases. + +### 3.12.1 (26 Apr, 2019) + +#### Fix + +* An issue that web content does not go back to its original position after keyboard dismissed on iOS. +* A crash when dismissing the web view on iOS 9 devices. +* An issue causes some files cannot be selected when uploading with a form and the file chooser. + +### 3.12.0 (10 Apr, 2019) + +#### Add + +* Now you can use `SetDragInteractionEnabled` to disable the drag interaction on iPad running iOS 11 or above. + +#### Fix + +* A issue which causes the non full screen web view position moving in some cases when soft keyboard is showing up. + +### 3.11.0 (27 Mar, 2019) + +#### Add + +* Add `SetCalloutEnabled` method to control the behavior when the user taps an image or link with long press or force touch gesture. Now you can choose not to display the context callout menu. + +#### Fix + +* Now the navigation bar on Android will automatically hide immediately when the soft keyboard dismissed. +* A workaround for regression on iOS 12 which causes selecting input fields in forms does not trigger the web view auto scrolling. + +### 3.10.2 (28 Feb, 2019) + +#### Fix + +* Fix a crash when selecting files from Downloads folder on certain Android devices when uploading. +* Support showing web view in cutout mode in Android. Now UniWebView will follow the cutout render setting. + +### 3.10.1 (15 Feb, 2019) + +#### Fix + +* An issue that lack of a placeholder method which causes code not compile on Windows. + +### 3.10.0 (9 Feb, 2019) + +#### Add + +* A method to turn off automatically prompt alert showing when received an HTTP auth challenge from server. Use `SetAllowHTTPAuthPopUpWindow` to control the behavior. +* Support open third party app with links of corresponding URL schemes. Now you can use a link to open other apps as long as it was registered. + +#### Fix + +* Performance issues when using some sync getter APIs on Android native side. + +### 3.9.2 (10 Jan, 2019) + +#### Fix + +* A problem that `SetZoomEnabled` not works correctly on iOS 12. +* Now `CanGoBack`, `CanGoForward` and `Url` getters also work for single page app page. + +### 3.9.1 (18 Dec, 2018) + +#### Fix + +* A potential issue causes file chooser not response correctly when user dismiss the permission prompt without choosing. +* Remove JavaScript Interface support for suppressing security warning from Google. + +### 3.9.0 (30 Nov, 2018) + +#### Add + +* A parameter for `Load` method to customize the read access URL for local file loading. It helps to load local resources under a different URL other than the current load page. + +#### Fix + +* A problem that read access URL not encoded correctly when special characters contained. +* An issue causes crash when changing screen orientation by code when closing the web view with a toolbar displayed. + +### 3.8.1 (24 Oct, 2018) + +#### Fix + +* Fix a potential crash when reference `RectTransform` is used to determine web view frame, while there is no cavans for some reason on the transform. + +### 3.8.0 (5 Sep, 2018) + +#### Add + +* A method to allow file access from file URLs. This could solve some problem when request in a cross origin way from local pages. However, by setting it to true may cause some potential security issue, so make your choice at the risk. + +#### Fix + +* A problem causing immersive mode flickering in Android 8.x. +* Post request on back button would work correctly. + +### 3.7.1 (26 Jun, 2018) + +#### Fix + +* A typo on "OnOrientationChanged" event. It was "OnOreintationChanged" and now we correct this issue in both code and documentation. + +### 3.7.0 (14 Jun, 2018) + +::: danger +From Unity 2018, Gradle is used as the default build system, so we updated the integration method to make UniWebView works better in the new build system. If you are upgrading UniWebView from an earlier version, please refer to the [Adapting to AAR File](https://docs.uniwebview.com/guide/adapting-to-aar-file.html) documentation. +::: + +#### Add + +* Compatible with Unity 2018.1 and gradle build system. Please note that you need some migration if you want to upgrade from an earlier version. + +### 3.6.1 (26 Apr, 2018) + +#### Fix + +* Compatible with Unity 2017.4. Now videos could be played correctly on Android devices in project exported by Unity 2017.4. + +--- + +### 3.6.0 (3 Apr, 2018) + +#### Add + +* OnWebContentProcessTerminatedDelegate event is added. This event will be raised when iOS system stops loading the web content for some reason (Usually due to memory pressure). Prior UniWebView versions will try to refresh the page for you automatically. However, that would not fix the problem in most cases. This event provides a chance for you to free as much as resources and do reloading/handling as you need. + +#### Fix + +* As issue which causes web view frame not set properly when using prefab with a pre-set reference rectangle transform. +* Some other minor internal fix. + +--- + +### 3.5.2 (28 Feb, 2018) + +#### Fix + +* An issue which causes POST data from HTML form is missing when a customized header field is set on iOS. +* Now customized header fields will be also added to image download requests on Android. + +--- + +### 3.5.1 (31 Jan, 2018) + +#### Fix + +* A potential issue which may cause game unresponsive when switching back to foreground when a web view's game object or its parent objects are inactive. +* An issue causes web view cannot be added to correct view in the first game run loop while splash screen is disabled. + +--- + +### 3.5.0 (22 Jan, 2018) + +#### Add + +* Images from Internet now could be downloaded to Download folder in Android. +* More consistent toolbar layout mechanism for toolbar on iOS. Now Auto Layout is used for layout toolbar, and `adjustInset` option works better. + +#### Fix + +* An issue which crashes macOS Editor when loading a local file in macOS 10.11 or earlier. +* iOS context menu (action bar) now could cover toolbar properly. +* A regression that makes setting text for toolbar done button title not working. +* No need to add support-v4 package anymore to support uploading files to server. +* Toolbar intersection with web view will now respect your frame setting first, then adjust its own height or top anchor. + +--- + +### 3.4.2 (28 Dec, 2017) + +#### Fix + +* Use new message sending method between native and C# script. Now all messages could be received even when the web view game object is inactive. +* Prevent `Init` with an empty name for security. + +--- + +### 3.4.1 (12 Dec, 2017) + +#### Fix + +* Fix an issue on Android that getting some web view properties inside web view events may freeze the loading process. +* The toolbar will not show automatically when you are using a prefab with "Use Toolbar" on. Now the toolbar will follow the show and hide state of the web view itself. +* Fix an error in Editor when stop playing mode while a web view is being shown. +* Upgrade to Android build SDK to API Level 26. (But still support from Android 5.0.) + +--- + +### 3.4.0 (7 Nov, 2017) + +UniWebView now requires Xcode 9 with iOS SDK 11 to build. If you are still using Xcode 8 and iOS 10 SDK, please use UniWebView 3.3.x instead. + +#### Add + +* Better cookie management for iOS 11. On iOS 11, now UniWebView uses the newly added HTTP cookie store to get more stable cookie states. +* Update web view layout and toolbar for iPhone X screen. +* A method for printing current web view to a printer or air printer. + +#### Fix + +* A potential issue which may cause cookie lost during 301 or 302 redirecting. + +--- + +### 3.3.2 (6 Oct, 2017) + +#### Fix + +* A crash when games are built against iOS 11 SDK and setting screen orientation with Unity API while the web view showing. + +--- + +### 3.3.1 (6 Oct, 2017) + +#### Fix + +* A crash when setting screen orientation with Unity API while the web view showing. +* Compatible with iOS 11 SDK and Xcode 9. +* Due to a Unity High Sierra support issue, UniWebView 3 now require Unity 5.6.3 at least. + +--- + +### 3.3.0 (9 Sep, 2017) + +#### Add + +* Support HTTP Basic and HTTP Digest authentication. A native pop-up will be displayed when there is a challenge to ask users to provide user name and password. +* Support "intent" and "market" URL scheme. Now any valid "intent://" URL will be handled on Android. If target intent is not found, and there is no fallback URL provided, UniWebView will try to open the application page on Play Market. The "market://" URL will be navigated to Play Market. + +#### Fix + +* A problem which caused hidden web view also receiving touch event on Android when multiple web views are used. +* Fix an issue which causes crash when uploading a camera captured photo on some Android devices. +* Improvement on loading performance a bit on Android. + +--- + +### 3.2.0 (3 Sep, 2017) + +#### Add + +* An option to URL or HTML string loading APIs to skip encoding, it is useful when you need to encode the url yourself instead of using the default encoding rule in UniWebView. +* An option to cookie setting and getting APIs to skip encoding. + +#### Fix + +* An issue on Android which cause the default user agent cannot be retrieved correctly before the first request. +* A memory leak on macOS Editor that web view window not get closed correctly. +* More accurate scaling calculating in Zoomed Display mode on iOS. +* Event touch could be handled correctly in Android when multiple web views shown now. +* The URL encoding will not be applied to an already encoded input URL now. +* The local file loading will not be loaded again in current view. This prevents a wrong behavior when loading a local page containing iframe tag. +* The UniWebViewMessage will now respect the encoded url parameters and queries. + +--- + +### 3.1.4 (17 Aug, 2017) + +#### Fix + +* Fix a problem which could cause web view alpha value not correct in some situation after transition with fade animation. +* Fix position issue when showing web view with both edge and fade animation. + +--- + +### 3.1.3 (9 Aug, 2017) + +#### Fix + +* A linking issue when running with a lower iOS SDK in Xcode. + +--- + +### 3.1.2 (6 Aug, 2017) + +#### Fix + +* Now `SetWebContentsDebuggingEnabled` also works for macOS Editor build. Set it to true and you could right click in the web view in editor to show an inspector for debugging purpose. +* Fix a flickering of navigation bar when loading a new page with immersive mode on Android. +* A compiling error when build iOS target on a Windows editor. +* A problem that built-in some schemes (`mailto`, `sms` and `tel`) not handled correctly on iOS and macOS. +* Fix some deprecated methods of build system for Android. + +--- + +### 3.1.1 (21 Jul, 2017) + +#### Fix + +* Local file URL with special characters now can be corrected encoded when loading. +* Avoid unhandled Show method calling right after a Hide method. Now, the Hide method will be ignore if the web view is already hidden. +* All three kinds of render mode for canvas (`ScreenSpaceOverlay`, `ScreenSpaceCamera` and `WorldSpace`) are now supported when using `RectTransform` to determine web view position and size. +* Array query in `UniWebViewMessage` should work as expected. Now a query like "?a[]=1&a[]=2" will be parsed to "1,2" in the result message. + +--- + +### 3.1.0 (14 Jul, 2017) + +#### Add + +* A helper method `UniWebViewHelper.PersistentDataURLForPath` to return a url string for files under `persistentDataPath`. +* A method to enable user resizing for web view windows on macOS Editor. +* Upgrade to new build tool chain to get better optimized binary for both iOS and Android targets. + +#### Fix + +* An issue which might cause url encoding returns wrong result when the original url contains space for other special characters. + +--- + +### 3.0.1 (3 Jul, 2017) + +#### Fix + +* Setting cookies from JavaScript now could work correctly. +* Allowing back compatibility for mixed content loading in Android. +* Stopping loading now could trigger page loading error event. +* Fully bit code support is now enabled for iOS build. + +--- + +### 3.0.0 (27 Jun, 2017) + +::: danger +3.0.0 is a major update of UniWebView. We rewrote the whole software from scratch to bring your experience of using a web view in Unity to a next level. Be caution it is not compatible with UniWebView 2, there are quite a few breaking changes in this version. For migration from UniWebView 2 in detail, visit our [Migration Guide](https://docs.uniwebview.com/guide/migration-guide.html) in documentation. To know the highlight of the version, check [this page](https://docs.uniwebview.com/guide/version-highlight.html) for more. +::: + +#### Add + +* Better way to set frame of the web view. You can also use a reference `RectTransform` to set position and size. +* Use `WKWebView` instead of `UIWebView` on iOS. +* New pop-up style Unity Editor support on macOS. It is a fully functional tool for debugging purpose. +* A new way to setup bridging between Unity and Cocoa native. Now there is no message sending delay. +* You can now set the position of toolbar to top or bottom on iOS. +* A leveled logger to log all UniWebView related information. See [UniWebViewLogger](https://docs.uniwebview.com/api/uniwebviewlogger.html) documentation for more. +* Use a payload based callback API like transition and JavaScript related methods. It takes more data. See [UniWebViewNativeResultPayload]https://docs.uniwebview.com(/api/uniwebviewnativeresultpayload.html). +* SSL exception for white listed domain. It is useful for a un-trusted certification but you still want to access. +* A method to get current web view HTML content as a string. + +#### Fix + +* UniWebView Android no longer requires to be the main activity. +* Uploading now could work properly on all supported devices. +* The url scheme based message now supports UTF-8 and url encoding directly. +* Now the customized header field will be existing for all requests until removed, not only the first one. + +--- + +### 2.11.1 (22 May, 2017) + +#### Fix + +* A performance issue which causes the camera scene gets slow and laggy when used with Vuforia. + +--- + +### 2.11.0 (28 Apr, 2017) + +#### Add + +* An API to ignore SSL cert error for a certain host in Android. +* Add Firebase as built-in third party jar supporting. + +#### Fix + +* An icon used to demonstrate UniWebView. + +--- + +### 2.10.0 (28 Feb, 2017) + +#### Add + +* An API to set allowing video auto-play. Call `SetAllowAutoPlay` on the web view for it. Please note that you also need to add an "auto-play" property in the video tag to enable auto-play in the web page. +* An API to enable inline video play for iOS. By default, iOS video play will be pop to full-screen. By calling SetAllowInlinePlay with a true flag, you can play video inline on iOS. Please note you also need to add an "inline" property in your video tag to support it. +* SetCookie and GetCookie methods to set and get a cookie for a specified URL and key. + +#### Fix + +* A potential issue that cleaning cookie did not work in some case. Since the logic of current cleaning cookie is not correct, we also marked the original CleanCookie method to be obsoleted. You should now use SetCookie method to set a cookie value to empty for cleaning purpose. + +--- + +### 2.9.2 (31 Jan, 2017) + +#### Fix + +* Pre-compiled jar file for Google VR activity. +* An issue which causes web view cannot be opened correctly in some old Android devices. + +--- + +### 2.9.1 (7 Nov, 2016) + +#### Fix + +* Add a null check for Android web view. This prevented a potential crash when navigating from javascript + +--- + +### 2.9.0 (29 Sep, 2016) + +#### Add + +* Android remote web content debugging support. Now you can debug your web page in Android with Chrome. Just set `SetWebContentsDebuggingEnabled` with true to enable it. +* Ability for loading page with overview mode for Android. + +#### Fix + +* Now all key down events are forwarded to Unity side by OnKeyDown callback in Android, even for TV remote controller and real device keys. + +--- + +### 2.8.0 (29 Jul, 2016) + +#### Add + +* An option (`openLinksInExternalBrowser`) that all the links should be opened in an external browser or not. It will be useful if you want to open a URL in Mobile Safari or Chrome, instead of opening it in UniWebView. Default is false. +* Now you can set the Done button title from Unity. Use `SetDoneButtonText` to customize the button title. +* LGC SDK built-in support. + +--- + +### 2.7.1 (3 Apr, 2016) + +#### Fix + +* Now the keyboard will also be dismissed in iOS when you call Hide on the web view with the keyboard showing. +* A potential problem of activity type casting which might cause the app crashes when you use UniWebView with some other third party activity. +* Add "singleTop" to launch mode in Android to prevent crash from multiple activity racing. + +--- + +### 2.7.0 (11 Mar, 2016) + +#### Add + +* Add APIs for setting visibility of vertical and horizontal scroll bar of the web view. + +#### Fix + +* Update pre-compiled jar file for Prime31 and CardBoard, to be compatible to their latest SDKs. +* Return an empty string for asset path string API, so it will compile even you switch to a platform that UniWebView does not support. +* Fix a problem which prevents you from settings background color to transparent ones. It is a regression in version 2.6.0 and now it will not show a black background color anymore. +* Not disabling hardware accelerating when Settings background color with alpha for Android. This would improve the performance of using a transparent background a lot. +* A potential issue that will fail in type casting in Android activity type. This would improve the compatibility when working with other third party packages which tries to convert the Unity activity. + +--- + +### 2.6.0 (15 Feb, 2016) + +#### Add + +* Rewrite video playing for Android web view. Now you could expect a better and stable video playback for both Youtube and Vimeo. + +#### Fix + +* Remove custom activity which is not needed anymore. + +--- + +### 2.5.2 (27 Jan, 2016) + +#### Fix + +* Use UnityPlayerActivity instead. This makes UniWebView compatible with Unity 5.4 (current in beta). + +--- + +### 2.5.1 (22 Jan, 2016) + +#### Fix + +* A crash issue in editor when you use AddUrlScheme. + +--- + +### 2.5.0 (31 Dec, 2015) + +#### Add + +* Support for adding customize header field. +* A helper method to generate streaming asset url for local pages. +* Add AppFlyer jar file. + +#### Fix + +* Hide transition callback will work correctly for Android now. +* Improve performance for OS X Editor version. + +--- + +### 2.4.1 (11 Dec, 2015) + +#### Fix + +* Compatible with Unity 5.3.0's new OS X OpenGL Core for editor. +* Clean some debug log. +* Update default page in demo scene. +* Set default user agent of Editor version to an iPhone agent. So you could get the mobile version of web view in Editor. + +::: danger +Notice: Unity dropped Windows Phone 8 support officially from 5.3. UniWebView will not continue development for Windows Phone as well from this version. +::: + +Reason: The amount of our Windows Phone users is very few compared to iOS and Android (it is less than 1% share according to report). +However, if we want to to support Windows Store App with Windows Phone 8.1 SDK or Windows 10 SDK, it would take even more time than either of other platforms. + +Since the Windows Phone SDK itself is not backwards compatible, the transition from Windows 8 to 8.1 or 10 means we need to rewrite all code in the package. + +We have only limited resource. To make sure we could build the asset in a better quality for most of our users, we decided to focus back to iOS and Android only from next version. + +The current Windows Phone 8 support (UniWebViewWP.dll) will be kept in later versions of UniWebView for a while, but we are sorry that it doesn't seem to get updated anymore. + +--- + +### 2.4.0 (4 Dec, 2015) + +#### Add + +* Built-in show/hide transition. You could now show or hide the web view with a transition effect. Currently we support fade in/out and transition from/to one of screen edges. Please take a look at reference of Show() and Hide() for more. + Add: Recreate new demo scenes as a better tutorial. Now most of the useful features are contained in the demo scenes, with fully commented script to show how to use them. +* Now you can use "ESC" in OS X Editor to go back or close the web view. + +#### Fix + +* The color of iOS toolbar is now white. This fixed an issue that the clear background tool bar will become black if no web page is underneath. +* Fix an issue which cause show tool bar property not working in some situation. +* Adjust the behavior of insets, it is a preparation for later feature like insets translating. The API of insets remains the same now. + +#### Remove + +::: danger +Notice: Unity will drop Windows Phone 8 support officially from 5.3. UniWebView will not continue development for Windows Phone as well from the next version. +::: + +Reason: The amount of our Windows Phone users is very few compared to iOS and Android (it is less than 1% share according to report). +However, if we want to to support Windows Store App with Windows Phone 8.1 SDK or Windows 10 SDK, it would take even more time than either of other platforms. + +Since the Windows Phone SDK itself is not backwards compatible, the transition from Windows 8 to 8.1 or 10 means we need to rewrite all code in the package. + +We have only limited resource. To make sure we could build the asset in a better quality for most of our users, we decided to focus back to iOS and Android only from next version. + +The current Windows Phone 8 support (UniWebViewWP.dll) will be kept in later versions of UniWebView for a while, but we are sorry that it doesn't seem to get updated anymore. + +--- + +### 2.3.1 (5 Nov, 2015) + +#### Fix + +* An issue that script is missing in the prefab if you import the asset in a new version of Unity. +* Compatibility for Unity 5.2.2 editor. + +--- + +### 2.3.0 (13 Oct, 2015) + +#### Add + +* SMS link support for Android devices. + +--- + +### 2.2.5 (8 Oct, 2015) + +#### Fix + +* Compatibility for Unity 5.2.1 editor. + +--- + +### 2.2.4 (4 Oct, 2015) + +#### Fix + +* A status bar truncating issue which may appears on some Android devices when user show/hide the soft keyboard for several times. + +--- + +### 2.2.3 (27 Sep, 2015) + +* An API to add trusted sites for Android. You will need to add your site url to the white list if you need to request the protected resources of Android devices (such as microphone or camera). +* Add third party support for Craftar. + +#### Fix + +* A vulnerability that accept SSL connect even an error happens. Now UniWebView will use the default behavior of system and reject all un-trusted SSL connection. It will protect your web content from possible man-in-the-middle attacks. At the same time, it means you have to use a valid certification even if you are in test environment. + +* A null exception when input in a text field in Editor. + +--- + +### 2.2.2 (12 Sep, 2015) + +#### Fix + +* An issue in Unity 5.2 which causes the web view not showing correctly in Unity Editor. +* Alert compatibility for iOS in Unity 5.2. + +--- + +### 2.2.1 (4 Sep, 2015) + +#### Add + +* PIs to get navigation state of current web view. Now you can use CanGoBack() and CanGoForward() to determine whether there is a page to go back or forward. + +#### Fix + +* Optimize performance for 64-bit OSX Editor version. + +--- + +### 2.2.0 (22 Aug, 2015) + +#### Add + +* An API to set background color for the web view. + +#### Fix + +* The video will paused when app switched to background in Android devices now. +* An issue causes the loading indicator not removed in Windows Phone 8 devices when dismiss the web view. +* Add Neatplugin and RigidFace to default supported third party jar. + +--- + +### 2.1.3 (30 Apr, 2015) + +#### Fix + +* File chooser for Android 5.0+. + +--- + +### 2.1.2 (28 Apr, 2015) + +#### Fix + +* An issue on Android which causes screen remaining black when user taps back button when playing a full-screen Youtube video. + +--- + +### 2.1.1 (26 Apr, 2015) + +#### Add + +* API for setting and getting alpha value. + +#### Fix + +* An issue which causes spinner not hidden when web view dismissed by done button. + +--- + +### 2.1.0 (22 Apr, 2015) + +#### Add + +* Add immersive mode support for Android for API Level 19 and above. +* Google CardBoard support. You can now find a pre-built CardBoard jar library. + +#### Fix + +* A crash which causes crash when setting insets to an invalid value. + +--- + +### 2.0.0 (15 Mar, 2015) + +#### Add + +* Support for Windows Phone 8 and 8.1. Please note you need to add WebBrowser capability in Windows Phone's manifest file after exported from Unity. +* Support for Unity 5. If you upgrade from UniWebView 1.x, you need to remove the old package and reimport again. +* 64 bit support for Mac Editor version, since Unity 5 is now a 64-bit app. + +#### Fix + +* An issue which may cause the cache can not be cleaned completed in iOS. +* A serialize issue which may cause editor crash in some occasion. + +::: danger +Notice: This version is not compatible with Unity 4.x. If you need to use UniWebView on Unity 4.x, please use UniWebView 1.x instead. You can find more information about the earlier version on Asset Store: https://assetstore.unity3d.com/jp/#!/content/12476 +::: + +--- + +### 1.9.0 (10 Feb, 2015) + +::: warning +1.9.x will be the last version support Unity 4.x. Due to the huge difference between Unity 4 and 5, we decide to make a major update as well. Please keep an eye on our website (https://uniwebview.onevcat.com) to know more information about Unity 5 compatible version. +::: + +#### Fix + +* An issue cause Mac Editor can not be used in 64bit environment. +* Removed source folder and zipped them to avoid a potential compile error. +* Removed a deprecated method to avoid compile error. + +--- + +### 1.8.1 (9 Nov, 2014) + +#### Fix + +* Improve performance for Mac Editor a lot. +* An issue which cause spinner can not hide when the web view removed by code from Unity. +* Update Android build target. + +--- + +### 1.8.0 (5 Nov, 2014) + +#### Fix + +Add: A method to change the user agent of the web view. Now you can use the SetUserAgent method to set customized user agent for the web view. +Add: The Mac Editor now supports for Xcode 6.1 and OSX Yosemite. + +* An orientation issue when you set game as a landscape one, while the web view can not rotated to portrait on iOS 8. + +--- + +### 1.7.3 (8 Oct, 2014) + +#### Fix + +* A issue which may cause crash on some Android device with system version 2.x. + +--- + +### 1.7.2 + +#### Add + +* An API for Android to enable wide view port support. Call SetUseWideViewPort(true) before loading any webpage containing viewport meta tag on Android to make it available. + +#### Fix + +* Now the viewport support for Android is disabled by default. Use the new added SetUseWideViewPort API to enable it if you are using viewport tag in your webpage. + +--- + +### 1.7.1 (7 Oct, 2014) + +#### Add + +* Insets setting for portrait and landscape mode. You can now set different portrait and landscape inset easier. If you need show your web content in both orientation, you might want to use the new `InsetsForScreenOreitation` event. See demo code for the usage. + +#### Fix + +* Viewport issue for some Android devices. Now the html's viewport should work correctly. +* Web view truncated issue when the y position set to 0 on some Android devices. This is an advanced fix continuing for version 1.6.1. +* An issue which causes auto-rotation not work on iOS 8 in some situation. +* The position of toolbar and spinner should be correct on iOS 8 now. +* A build error which stops the exported project compiling in Xcode 5 and iOS 7 SDK. + +--- + +### 1.7.0 (26 Sep, 2014) + +::: danger +This version dropped support for Unity 4.1.4. Now UniWebView starts from 4.2.2. And 1.7.x will be the last versions support Unity version below 4.4 (because there is a compile error in iOS 8 SDK in the exported Xcode project, which is annoying and makes the development harder). +::: + +#### Add + +* UniWebViewHelper.screenHeight and UniWebViewHelper.screenWidth. You can retrieve the screen size in "point" instead of "pixel" with these two new API. See the migrate guide below for more. +* "tel:" link support for Android. Now you can open the telephone UI by a link like "tel:12345678". +* An example in demo file, to show how to handle the auto-orientation, with keeping the layout unchanged in both portrait and landscape. +* iOS 8 and 5.5 inch iPhone 6 Plus support. + +#### Fix + +* The auto-orientation issue on iOS 8. Now it works for both iOS 8 SDK. +* Trim the url leading and trailing spaces, making the behaviors the same for iOS and Android. + +#### Deprecate + +* UniWebViewHelper.RunningOnRetinaIOS() is now deprecated due to 3x size of iPhone 6 Plus. Use UniWebViewHelper.screenHeight and UniWebViewHelper.screenWidth to decide the insets for retina display now. See the migrate guide below for more. + +#### Remove + +* Remove the long-ago deprecated Dismiss(). +* Remove support for Unity 4.1.4. + +> Migrate Guide - If you are using UniWebViewHelper.RunningOnRetinaIOS() to decide the insets of UniWebView, you may want to look at the Migrate Guide: + +Due to introduction of iPhone 6 Plus and its new @3x scale, the old way would not work well. Now, all screen-size-based insets calculation for UniWebView should NOT use RunningOnRetinaIOS anymore. Instead you should use UniWebViewHelper.screenHeight and UniWebViewHelper.screenWidth and specify the point directly. For example, if you want to show a web view taking the upper half of screen, before version 1.7.0, it might be something like this: + + int uiFactor = UniWebViewHelper.RunningOnRetinaIOS() ? 2 : 1; + int bottomInset = Screen.height / ( 2 * uiFactor ); + _webView.insets = new UniWebViewEdgeInsets(0,0,bottomInset,0); + +Right now, with the new API, you can just use this: + + int bottomInset = (int)(UniWebViewHelper.screenHeight * 0.5f); + _webView.insets = new UniWebViewEdgeInsets(0,0,bottomInset,0); + +No more ui factor and device-specified calculation needed. + +To make sure you can notice this change, the usage of RunningOnRetinaIOS() will cause an error now. You can just delete all usage of that, and change your insets code like the example above. + +--- + +### 1.6.1 (2 Sep, 2014) + +#### Add + +* A pre-compiled package for Vuforia's QCARPlayerNativeActivity activity. You can find it under the /UniWebView/Source/ThirdPartyJar folder. + +#### Fix + +* An issue which cause the web view can not be full screen on some Android tablet. +* Drop support for Android 2.2.x and earlier. So you can recompile the jar file with Android SDK 18 and later. + +--- + +### 1.5.4 (29 Jul, 2014) + +#### Fix + +* Keyboard overlap issue when text filed on Android. Now the web content will be scrolled up automatically. + +--- + +### 1.5.3 (16 Jul, 2014) + +#### Fix + +* A bug which causes an unexpected behavior when starting from other activities in Android. + +--- + +### 1.5.2 (19 Jun, 2014) + +#### Fix + +* A bug when setting insets in some Android devices. + +--- + +### 1.5.0 (1 Jun, 2014) + +#### Add + +* New download feature support for Android. +* Compatibility with Unity 4.5. + +#### Fix + +* Update Android recompile guide for Unity 4.5. +* Rotation problem when playing full screen video on iOS. Now the layout can work perfectly. + +--- + +### 1.4.2 (30 Apr, 2014) + +#### Fix + +* Fix errors when export from Unity for the platforms not supported in UniWebView. Be caution, this fix does not make UniWebView supporting for other platforms than iOS and Android. It just disabled UniWebView code and suspended the errors. + +--- + +### 1.4.1 (31 Mar, 2014) + +#### Add + +* An API for adding some javascript snippet to Android and iOS in runtime. Now you can dynamically add js code to your page when the game is running, instead of defining it in the web page before loading the web content. +* API for cleaning a specified cookie, instead of cleaning them all. +* A key down event on Android while the web view is activated. + +#### Fix + +* Improved the performance for Mac Editor. +* Some other small issues. + +> The parameters of LoadBeginDelegate is changed from 1.4.0. There is now an url parameter in the delegate. If you are using web view.currentUrl in the corresponding event, now please use this parameter instead of that. The currentUrl is updated only when web page loading finished or failed now. + +--- + +### 1.4.0 (12 Mar, 2014) + +#### Add + +* Add an API for clean cookies for the web view. +* Add an API for stop current loading of the web view. + +#### Fix + +* Change the logic when loading web view, now UniWebView will send all loading begin event back to Unity. +* An issue which cause Youtube video can not be automatically played in iOS. + +--- + +### 1.3.0 (11 Feb, 2014) + +#### Add + +#### Fix + +New: Customize url schemes. You can now add and remove the url schemes UniWebView is using. By using new API of AddUrlScheme and RemoveUrlScheme, you can now integrate some more third party service easier. +New: Support for location service of Android. + +* Some memory leak on iOS. + +--- + +### 1.2.6 (21 Jan, 2014) + +#### Add + +* Add bouncesEnable property to Android. You can set the bounce effect for Android as well. Default is false, which means not show the bounce effect on Android, and not bounce the web view on iOS. +* Add a refresh button in iOS's built-in tool bar. +* Add zoom feature to both iOS and Android. Now you can set the zoomEnable property to let your users zoom-in or zoom-out web view by a pinch gesture. +* Add Reload method, you can reload the current page now from code. + +#### Fix + +* Ignore the ssl check in Android, it is useful when you are testing your page with a certification you create yourself. Otherwise, you can not get pass from it. +* Log order issue on Android. Now the create and show events can be logged correctly. + +--- + +### 1.2.5 (9 Jan, 2014) + +#### Add + +* Add a bouncesEnable property to control the bounces when scroll the web view in iOS. The bounces effect is turned off by default, if you want it back, set this property to true. + +#### Fix + +* A problem causing the OnComplete event can not be raised correctly when load fails. +* A problem which causes the name of web view game object being appended instead of replaced. +* A problem with hiding the web view. Now the web view area could be clicked through correctly when hidden. + +#### Deprecate + +* `Dismiss()` is now deprecated, use `Hide()` to hide the web view. + +--- + +### 1.2.3 (25 Dec, 2013) + +#### Add + +* Support for "mailto" link for Android. + +#### Fix + +* A potential issue which may cause unity scene turning to black when switching back to game while web view opened. It might shows on some old Android devices. +* A problem which causes the source can not get compiled in Mono Develop. +* Update the Dismiss method to let it work as designed in Mac Editor and Android devices. It now behaviors as making the web view hidden instead of close and destroy it. You can use Show to make it visible again after dismissing it. + +--- + +### 1.2.2 (18 Dec, 2013) + +#### Add + +* An option to disable the back button on Android device. It is useful when you don't want users dismiss the web view (for example you want to use web view as part of your UI). + +#### Fix + +* Change the local file loading back to previous because the new method can not handle base url very well. +* An issue which caused current url can not be retrieved properly for Android. + +--- + +### 1.2.1 (12 Dec, 2013) + +#### Add + +* A property to get the current page url. You can know on which page now when you using UniWebView. +* An event when the page begins to load. Not only the first page load from code, but also all the page loading by clicking links on the page. + +#### Fix + +* A mistake in transparent setting method in Android. +* Background can be setting to transparent now in Android, from 2.x to 4.x (and later I think). +* Make the local html load easier to use. Now just set the correct streaming asset path, and load. No more platform-specified step. + +--- + +### 1.2.0 (7 Dec, 2013) + +#### Add + +* A spinner is added to web view, which will show when the webpage is under loading. The spinner is on by default, if you don't want it, you can set it not show by the SetShowSpinnerWhenLoading method of UniWebView. +* We also added a text label in the spinner, to show some information to your users. +* Added an OnEvalJavaScriptFinished event for evaluate js script. Now EvaluatingJavaScript will not return a value, but raise the event. So you can use the same API for both iOS and Android. +* Local file load for Android 4.x. + +#### Fix + +* Rewrote all the Android native code, to make it working properly under Unity 4.3. +* A problem which may cause unity game scene disappeared when game goes to background with web view opened in some old Android devices. + +--- + +### 1.1.7 (2 Dec, 2013) + +#### Add + +* Support for loading local file in Android. + +#### Fix + +* A bug in the demo which causes an exception when you click the web page of the demo. +* A problem which causes the plugin not working sometimes in Editor. + +--- + +### 1.1.6 (28 Nov, 2013) + +#### Fix + +* A problem the file input tag can not trigger a file chooser in Android. + +--- + +### 1.1.3 (21 Nov, 2013) + +#### Add + +* Add a method to the web view for loading from a html string. +* Add some demo script to tell demonstrate how to load a local html file. + +#### Fix + +* A problem when users close the web view with soft keyboard showing in Android. + +--- + +### 1.1.2 (16 Nov, 2013) + +#### Add + +* A better and more interesting demo scene to explain how to make the UniWebView work. + +#### Fix + +* A problem which cause the keyboard not working on Android. +* A rotation issue which cause the web view can not rotate correctly in iOS. + +--- + +### 1.1.0 (9 Nov, 2013) + +#### Add + +* Add Youtube video playing support for Android. +* Add a tool bar to iOS. +* The users can use back button (Android) or a native toolbar (iOS) to close the web view now. +* Add an event to control whether the web view can be closed or not. + +#### Fix + +* Update the demo scene to make it clearer and more interesting. + +--- + +### 1.0.1 (1 Nov, 2013) + +Init release + + diff --git a/Assets/UniWebView/CHANGELOG.md.meta b/Assets/UniWebView/CHANGELOG.md.meta new file mode 100644 index 00000000..63a59cae --- /dev/null +++ b/Assets/UniWebView/CHANGELOG.md.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f7ee8c3eb642344b08f4ceeb53d70cd1 +timeCreated: 1497057465 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Demo.meta b/Assets/UniWebView/Demo.meta new file mode 100644 index 00000000..d0394e67 --- /dev/null +++ b/Assets/UniWebView/Demo.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 565d674726c3d499cade2709dd955ad0 +folderAsset: yes +timeCreated: 1536753564 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Demo/UniWebViewDemo.unity b/Assets/UniWebView/Demo/UniWebViewDemo.unity new file mode 100644 index 00000000..6b7aa963 --- /dev/null +++ b/Assets/UniWebView/Demo/UniWebViewDemo.unity @@ -0,0 +1,337 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 3 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 0 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 0 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 500 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 500 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 0 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1001 &783622082 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 4960404783511462, guid: 7e3f16a6f6303419cbd9837f6c746de4, type: 3} + propertyPath: m_RootOrder + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4960404783511462, guid: 7e3f16a6f6303419cbd9837f6c746de4, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4960404783511462, guid: 7e3f16a6f6303419cbd9837f6c746de4, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4960404783511462, guid: 7e3f16a6f6303419cbd9837f6c746de4, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4960404783511462, guid: 7e3f16a6f6303419cbd9837f6c746de4, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4960404783511462, guid: 7e3f16a6f6303419cbd9837f6c746de4, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4960404783511462, guid: 7e3f16a6f6303419cbd9837f6c746de4, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4960404783511462, guid: 7e3f16a6f6303419cbd9837f6c746de4, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4960404783511462, guid: 7e3f16a6f6303419cbd9837f6c746de4, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 114939446366399424, guid: 7e3f16a6f6303419cbd9837f6c746de4, + type: 3} + propertyPath: urlOnStart + value: https://docs.uniwebview.com/guide/ + objectReference: {fileID: 0} + - target: {fileID: 114939446366399424, guid: 7e3f16a6f6303419cbd9837f6c746de4, + type: 3} + propertyPath: frame.width + value: 844 + objectReference: {fileID: 0} + - target: {fileID: 114939446366399424, guid: 7e3f16a6f6303419cbd9837f6c746de4, + type: 3} + propertyPath: frame.height + value: 390 + objectReference: {fileID: 0} + - target: {fileID: 114939446366399424, guid: 7e3f16a6f6303419cbd9837f6c746de4, + type: 3} + propertyPath: referenceRectTransform + value: + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 7e3f16a6f6303419cbd9837f6c746de4, type: 3} +--- !u!1 &890151856 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 890151859} + - component: {fileID: 890151858} + - component: {fileID: 890151857} + m_Layer: 0 + m_Name: EventSystem + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &890151857 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 890151856} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3} + m_Name: + m_EditorClassIdentifier: + m_HorizontalAxis: Horizontal + m_VerticalAxis: Vertical + m_SubmitButton: Submit + m_CancelButton: Cancel + m_InputActionsPerSecond: 10 + m_RepeatDelay: 0.5 + m_ForceModuleActive: 0 +--- !u!114 &890151858 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 890151856} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_FirstSelected: {fileID: 0} + m_sendNavigationEvents: 1 + m_DragThreshold: 10 +--- !u!4 &890151859 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 890151856} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1313296981 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1313296986} + - component: {fileID: 1313296985} + - component: {fileID: 1313296982} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &1313296982 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1313296981} + m_Enabled: 1 +--- !u!20 &1313296985 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1313296981} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &1313296986 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1313296981} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/UniWebView/Demo/UniWebViewDemo.unity.meta b/Assets/UniWebView/Demo/UniWebViewDemo.unity.meta new file mode 100644 index 00000000..2683ee36 --- /dev/null +++ b/Assets/UniWebView/Demo/UniWebViewDemo.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 938c077f40a814d4584ce2ad17947cf3 +timeCreated: 1536753573 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Editor.meta b/Assets/UniWebView/Editor.meta new file mode 100644 index 00000000..50aa7ecb --- /dev/null +++ b/Assets/UniWebView/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5f0047c1c8c8348de9d66b0496b353e1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Editor/AndroidManifest.cs b/Assets/UniWebView/Editor/AndroidManifest.cs new file mode 100644 index 00000000..79309f0a --- /dev/null +++ b/Assets/UniWebView/Editor/AndroidManifest.cs @@ -0,0 +1,142 @@ +using System.Xml; +using System.Collections; +using System.Text; +using System.IO; + +internal class UniWebViewAndroidXmlDocument : XmlDocument { + private string path; + protected XmlNamespaceManager nameSpaceManager; + public readonly string AndroidXmlNamespace = "http://schemas.android.com/apk/res/android"; + + public UniWebViewAndroidXmlDocument(string path) { + this.path = path; + using (var reader = new XmlTextReader(path)) { + reader.Read(); + Load(reader); + } + nameSpaceManager = new XmlNamespaceManager(NameTable); + nameSpaceManager.AddNamespace("android", AndroidXmlNamespace); + } + + public string Save() { + return SaveAs(path); + } + + public string SaveAs(string path) { + using (var writer = new XmlTextWriter(path, new UTF8Encoding(false))) { + writer.Formatting = Formatting.Indented; + Save(writer); + } + return path; + } +} + +internal class UniWebViewAndroidManifest : UniWebViewAndroidXmlDocument { + private readonly XmlElement ManifestElement; + private readonly XmlElement ApplicationElement; + + public UniWebViewAndroidManifest(string path) : base(path) { + ManifestElement = SelectSingleNode("/manifest") as XmlElement; + ApplicationElement = SelectSingleNode("/manifest/application") as XmlElement; + } + + private XmlAttribute CreateAndroidAttribute(string key, string value) { + XmlAttribute attr = CreateAttribute("android", key, AndroidXmlNamespace); + attr.Value = value; + return attr; + } + + internal XmlNode GetActivityWithLaunchIntent() { + return + SelectSingleNode( + "/manifest/application/activity[intent-filter/action/@android:name='android.intent.action.MAIN' and " + + "intent-filter/category/@android:name='android.intent.category.LAUNCHER']", + nameSpaceManager); + } + + internal bool SetUsesCleartextTraffic() { + bool changed = false; + if (ApplicationElement.GetAttribute("usesCleartextTraffic", AndroidXmlNamespace) != "true") { + ApplicationElement.SetAttribute("usesCleartextTraffic", AndroidXmlNamespace, "true"); + changed = true; + } + return changed; + } + + internal bool SetHardwareAccelerated() { + bool changed = false; + var activity = GetActivityWithLaunchIntent() as XmlElement; + if (activity.GetAttribute("hardwareAccelerated", AndroidXmlNamespace) != "true") { + activity.SetAttribute("hardwareAccelerated", AndroidXmlNamespace, "true"); + changed = true; + } + return changed; + } + + internal bool AddCameraPermission() { + bool changed = false; + if (SelectNodes("/manifest/uses-permission[@android:name='android.permission.CAMERA']", nameSpaceManager).Count == 0) { + var elem = CreateElement("uses-permission"); + elem.Attributes.Append(CreateAndroidAttribute("name", "android.permission.CAMERA")); + ManifestElement.AppendChild(elem); + changed = true; + } + if (SelectNodes("/manifest/uses-feature[@android:name='android.hardware.camera']", nameSpaceManager).Count == 0) { + var elem = CreateElement("uses-feature"); + elem.Attributes.Append(CreateAndroidAttribute("name", "android.hardware.camera")); + ManifestElement.AppendChild(elem); + changed = true; + } + return changed; + } + + internal bool AddMicrophonePermission() { + bool changed = false; + if (SelectNodes("/manifest/uses-permission[@android:name='android.permission.MICROPHONE']", nameSpaceManager).Count == 0) { + var elem = CreateElement("uses-permission"); + elem.Attributes.Append(CreateAndroidAttribute("name", "android.permission.MICROPHONE")); + ManifestElement.AppendChild(elem); + changed = true; + } + if (SelectNodes("/manifest/uses-feature[@android:name='android.hardware.microphone']", nameSpaceManager).Count == 0) { + var elem = CreateElement("uses-feature"); + elem.Attributes.Append(CreateAndroidAttribute("name", "android.hardware.microphone")); + ManifestElement.AppendChild(elem); + changed = true; + } + return changed; + } + + internal bool AddReadExternalStoragePermission() { + bool changed = false; + if (SelectNodes("/manifest/uses-permission[@android:name='android.permission.READ_EXTERNAL_STORAGE']", nameSpaceManager).Count == 0) { + var elem = CreateElement("uses-permission"); + elem.Attributes.Append(CreateAndroidAttribute("name", "android.permission.READ_EXTERNAL_STORAGE")); + ManifestElement.AppendChild(elem); + changed = true; + } + return changed; + } + + internal bool AddWriteExternalStoragePermission() { + bool changed = false; + if (SelectNodes("/manifest/uses-permission[@android:name='android.permission.WRITE_EXTERNAL_STORAGE']", nameSpaceManager).Count == 0) { + var elem = CreateElement("uses-permission"); + elem.Attributes.Append(CreateAndroidAttribute("name", "android.permission.WRITE_EXTERNAL_STORAGE")); + ManifestElement.AppendChild(elem); + changed = true; + } + return changed; + } + + internal bool AddAccessFineLocationPermission() { + bool changed = false; + if (SelectNodes("/manifest/uses-permission[@android:name='android.permission.ACCESS_FINE_LOCATION']", nameSpaceManager).Count == 0) { + var elem = CreateElement("uses-permission"); + elem.Attributes.Append(CreateAndroidAttribute("name", "android.permission.ACCESS_FINE_LOCATION")); + ManifestElement.AppendChild(elem); + changed = true; + } + return changed; + } +} \ No newline at end of file diff --git a/Assets/UniWebView/Editor/AndroidManifest.cs.meta b/Assets/UniWebView/Editor/AndroidManifest.cs.meta new file mode 100644 index 00000000..ccf5d026 --- /dev/null +++ b/Assets/UniWebView/Editor/AndroidManifest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d09054fcc76964295a49868566075973 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Editor/BuildGradle.cs b/Assets/UniWebView/Editor/BuildGradle.cs new file mode 100644 index 00000000..7e2ad5d8 --- /dev/null +++ b/Assets/UniWebView/Editor/BuildGradle.cs @@ -0,0 +1,344 @@ +using System.Collections.Generic; +using UnityEngine; +using System.IO; +using System.Text; +using System; + +public class UniWebViewGradleConfig +{ + private UniWebViewGradleNode m_root; + private String m_filePath; + private UniWebViewGradleNode m_curNode; + + public UniWebViewGradleNode ROOT + { + get { return m_root; } + } + + public UniWebViewGradleConfig(string filePath) + { + string file = File.ReadAllText(filePath); + TextReader reader = new StringReader(file); + + m_filePath = filePath; + m_root = new UniWebViewGradleNode("root"); + m_curNode = m_root; + + StringBuilder str = new StringBuilder(); + bool inDoubleQuote = false; + bool inSingleQuote = false; + + while (reader.Peek() > 0) + { + char c = (char)reader.Read(); + switch (c) + { + // case '/': + // if (reader.Peek() == '/') + // { + // reader.Read(); + // string comment = reader.ReadLine(); + // Debug.Log("Comment line: " + comment); + // m_curNode.AppendChildNode(new UniWebViewGradleCommentNode(comment, m_curNode)); + // } + // else + // { + // str.Append('/'); + // } + // break; + case '\n': + case '\r': + { + var strf = FormatStr(str); + if (!string.IsNullOrEmpty(strf)) + { + m_curNode.AppendChildNode(new UniWebViewGradleContentNode(strf, m_curNode)); + } + } + str = new StringBuilder(); + break; + case '\t': + { + var strf = FormatStr(str); + if (!string.IsNullOrEmpty(strf)) + { + str.Append(" "); + } + break; + } + case '{': + { + if (inDoubleQuote || inSingleQuote) { + break; + } + var n = FormatStr(str); + if (!string.IsNullOrEmpty(n)) + { + UniWebViewGradleNode node = new UniWebViewGradleNode(n, m_curNode); + m_curNode.AppendChildNode(node); + m_curNode = node; + } + } + str = new StringBuilder(); + break; + case '}': + { + if (inDoubleQuote || inSingleQuote) { + break; + } + var strf = FormatStr(str); + if (!string.IsNullOrEmpty(strf)) + { + m_curNode.AppendChildNode(new UniWebViewGradleContentNode(strf, m_curNode)); + } + m_curNode = m_curNode.PARENT; + } + str = new StringBuilder(); + break; + case '\"': + inDoubleQuote = !inDoubleQuote; + str.Append(c); + break; + case '\'': + inSingleQuote = !inSingleQuote; + str.Append(c); + break; + default: + str.Append(c); + break; + } + } + + //Debug.Log("Gradle parse done!"); + } + + public void Save(string path = null) + { + if (path == null) + path = m_filePath; + File.WriteAllText(path, Print()); + //Debug.Log("Gradle parse done! " + path); + } + + private string FormatStr(StringBuilder sb) + { + string str = sb.ToString(); + str = str.Trim(); + return str; + } + public string Print() + { + StringBuilder sb = new StringBuilder(); + printNode(sb, m_root, -1); + return sb.ToString(); + } + private string GetLevelIndent(int level) + { + if (level <= 0) return ""; + StringBuilder sb = new StringBuilder(""); + for (int i = 0; i < level; i++) + { + sb.Append('\t'); + } + return sb.ToString(); + } + private void printNode(StringBuilder stringBuilder, UniWebViewGradleNode node, int level) + { + if (node.PARENT != null) + { + if (node is UniWebViewGradleCommentNode) + { + stringBuilder.Append("\n" + GetLevelIndent(level) + @"//" + node.NAME); + } + else + { + stringBuilder.Append("\n" + GetLevelIndent(level) + node.NAME); + } + + } + + if (!(node is UniWebViewGradleContentNode) && !(node is UniWebViewGradleCommentNode)) + { + if (node.PARENT != null) + { + stringBuilder.Append(" {"); + } + foreach (var c in node.CHILDREN) + { + printNode(stringBuilder, c, level + 1); + } + if (node.PARENT != null) + { + stringBuilder.Append("\n" + GetLevelIndent(level) + "}"); + } + } + } +} + +public class UniWebViewGradleNode +{ + protected List m_children = new List(); + protected UniWebViewGradleNode m_parent; + protected String m_name; + public UniWebViewGradleNode PARENT + { + get { return m_parent; } + } + + public string NAME + { + get { return m_name; } + } + + public List CHILDREN + { + get { return m_children; } + } + + public UniWebViewGradleNode(string name, UniWebViewGradleNode parent = null) + { + m_parent = parent; + m_name = name; + } + + public void Each(Action f) + { + f(this); + foreach (var n in m_children) + { + n.Each(f); + } + } + + public void AppendChildNode(UniWebViewGradleNode node) + { + if (m_children == null) m_children = new List(); + m_children.Add(node); + node.m_parent = this; + } + + public UniWebViewGradleNode TryGetNode(string path) + { + string[] subpath = path.Split('/'); + UniWebViewGradleNode cnode = this; + for (int i = 0; i < subpath.Length; i++) + { + var p = subpath[i]; + if (string.IsNullOrEmpty(p)) continue; + UniWebViewGradleNode tnode = cnode.FindChildNodeByName(p); + if (tnode == null) + { + Debug.Log("Can't find Node:" + p); + return null; + } + + cnode = tnode; + tnode = null; + } + + return cnode; + } + + public UniWebViewGradleNode FindChildNodeByName(string name) + { + foreach (var n in m_children) + { + if (n is UniWebViewGradleCommentNode || n is UniWebViewGradleContentNode) + continue; + if (n.NAME == name) + return n; + } + return null; + } + + public bool ReplaceContenStartsWith(string patten, string value) + { + foreach (var n in m_children) + { + if (!(n is UniWebViewGradleContentNode)) continue; + if (n.m_name.StartsWith(patten)) + { + n.m_name = value; + return true; + } + } + return false; + } + + public UniWebViewGradleContentNode ReplaceContenOrAddStartsWith(string patten, string value) + { + foreach (var n in m_children) + { + if (!(n is UniWebViewGradleContentNode)) continue; + if (n.m_name.StartsWith(patten)) + { + n.m_name = value; + return (UniWebViewGradleContentNode)n; + } + } + return AppendContentNode(value); + } + + /// + /// 添加子节点 + /// + /// + /// + public UniWebViewGradleContentNode AppendContentNode(string content) + { + foreach (var n in m_children) + { + if (!(n is UniWebViewGradleContentNode)) continue; + if (n.m_name == content) + { + Debug.Log("UniWebViewGradleContentNode with " + content + " already exists!"); + return null; + } + } + UniWebViewGradleContentNode cnode = new UniWebViewGradleContentNode(content, this); + AppendChildNode(cnode); + return cnode; + } + + + public bool RemoveContentNode(string contentPattern) + { + for(int i=0;i text.Contains("android.useAndroidX")); + bool hasJetifierProperty = lines.Any(text => text.Contains("android.enableJetifier")); + + StringBuilder builder = new StringBuilder(); + + foreach(string each in lines) { + builder.AppendLine(each); + } + + if (!hasAndroidXProperty) { + builder.AppendLine("android.useAndroidX=true"); + } + + if (!hasJetifierProperty && UniWebViewEditorSettings.GetOrCreateSettings().enableJetifier) { + builder.AppendLine("android.enableJetifier=true"); + } + + File.WriteAllText(filePath, builder.ToString()); + } +} \ No newline at end of file diff --git a/Assets/UniWebView/Editor/GradleProperty.cs.meta b/Assets/UniWebView/Editor/GradleProperty.cs.meta new file mode 100644 index 00000000..0c95b969 --- /dev/null +++ b/Assets/UniWebView/Editor/GradleProperty.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 62bf94600ac0f42c09fc261d7ab19e12 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Editor/UniWebView-CSharp.Editor.asmdef b/Assets/UniWebView/Editor/UniWebView-CSharp.Editor.asmdef new file mode 100644 index 00000000..bf45cb2c --- /dev/null +++ b/Assets/UniWebView/Editor/UniWebView-CSharp.Editor.asmdef @@ -0,0 +1,15 @@ +{ + "name": "UniWebView-CSharp.Editor", + "references": [], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Assets/UniWebView/Editor/UniWebView-CSharp.Editor.asmdef.meta b/Assets/UniWebView/Editor/UniWebView-CSharp.Editor.asmdef.meta new file mode 100644 index 00000000..16d33ccf --- /dev/null +++ b/Assets/UniWebView/Editor/UniWebView-CSharp.Editor.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: b6d0e5b49a073436cbcd56804553ee20 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Editor/UniWebViewEditorSettings.cs b/Assets/UniWebView/Editor/UniWebViewEditorSettings.cs new file mode 100644 index 00000000..eb18dfbb --- /dev/null +++ b/Assets/UniWebView/Editor/UniWebViewEditorSettings.cs @@ -0,0 +1,114 @@ +using UnityEngine; +using UnityEditor; +using System.Collections.Generic; +using System; +using System.IO; + +class UniWebViewEditorSettings: ScriptableObject +{ + const string assetPath = "Assets/Editor/UniWebView/settings.asset"; + + [SerializeField] + internal bool usesCleartextTraffic = false; + + [SerializeField] + internal bool writeExternalStorage = false; + + [SerializeField] + internal bool accessFineLocation = false; + + [SerializeField] + internal bool addsKotlin = true; + + [SerializeField] + internal bool addsAndroidBrowser = true; + + [SerializeField] + internal bool enableJetifier = true; + + internal static UniWebViewEditorSettings GetOrCreateSettings() { + var settings = AssetDatabase.LoadAssetAtPath(assetPath); + + if (settings == null) { + settings = ScriptableObject.CreateInstance(); + + Directory.CreateDirectory("Assets/Editor/UniWebView/"); + AssetDatabase.CreateAsset(settings, assetPath); + AssetDatabase.SaveAssets(); + } + + return settings; + } + + internal static SerializedObject GetSerializedSettings() { + return new SerializedObject(GetOrCreateSettings()); + } +} + +static class UniWebViewSettingsProvider { + static SerializedObject settings; + + #if UNITY_2018_3_OR_NEWER + private class Provider : SettingsProvider { + public Provider(string path, SettingsScope scope = SettingsScope.User): base(path, scope) {} + public override void OnGUI(string searchContext) { + DrawPref(); + } + } + [SettingsProvider] + static SettingsProvider UniWebViewPref() { + return new Provider("Preferences/UniWebView"); + } + #else + [PreferenceItem("UniWebView")] + #endif + static void DrawPref() { + EditorGUIUtility.labelWidth = 320; + if (settings == null) { + settings = UniWebViewEditorSettings.GetSerializedSettings(); + } + settings.Update(); + EditorGUI.BeginChangeCheck(); + + EditorGUILayout.BeginVertical(); + EditorGUILayout.LabelField("Android Manifest", EditorStyles.boldLabel); + + EditorGUI.indentLevel++; + EditorGUILayout.PropertyField(settings.FindProperty("usesCleartextTraffic")); + DrawDetailLabel("If you need to load plain HTTP content."); + + EditorGUILayout.PropertyField(settings.FindProperty("writeExternalStorage")); + DrawDetailLabel("If you need to download an image from web page."); + + EditorGUILayout.PropertyField(settings.FindProperty("accessFineLocation")); + DrawDetailLabel("If you need to enable location support in web view."); + EditorGUI.indentLevel--; + EditorGUILayout.EndVertical(); + + EditorGUILayout.BeginVertical(); + EditorGUILayout.LabelField("Gradle Build", EditorStyles.boldLabel); + + EditorGUI.indentLevel++; + + EditorGUILayout.PropertyField(settings.FindProperty("addsKotlin")); + DrawDetailLabel("Turn off this if another library is already adding Kotlin runtime."); + EditorGUILayout.PropertyField(settings.FindProperty("addsAndroidBrowser")); + DrawDetailLabel("Turn off this if another library is already adding 'androidx.browser:browser'."); + EditorGUILayout.PropertyField(settings.FindProperty("enableJetifier")); + DrawDetailLabel("Turn off this if you do not need Jetifier (for converting other legacy support dependencies to Android X)."); + + EditorGUILayout.EndVertical(); + + if (EditorGUI.EndChangeCheck()) { + settings.ApplyModifiedProperties(); + AssetDatabase.SaveAssets(); + } + EditorGUIUtility.labelWidth = 0; + } + + static void DrawDetailLabel(string text) { + EditorGUI.indentLevel++; + EditorGUILayout.LabelField(text, EditorStyles.miniLabel); + EditorGUI.indentLevel--; + } +} \ No newline at end of file diff --git a/Assets/UniWebView/Editor/UniWebViewEditorSettings.cs.meta b/Assets/UniWebView/Editor/UniWebViewEditorSettings.cs.meta new file mode 100644 index 00000000..eb5f99ca --- /dev/null +++ b/Assets/UniWebView/Editor/UniWebViewEditorSettings.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a403a09e241a0480a957591ea60fb785 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Editor/UniWebViewPostBuildProcessor.cs b/Assets/UniWebView/Editor/UniWebViewPostBuildProcessor.cs new file mode 100644 index 00000000..b3d2e832 --- /dev/null +++ b/Assets/UniWebView/Editor/UniWebViewPostBuildProcessor.cs @@ -0,0 +1,116 @@ +using UnityEditor; +using UnityEditor.Android; +using UnityEngine; +using System.IO; +using System.Text; + + +class UniWebViewPostBuildProcessor : IPostGenerateGradleAndroidProject +{ + public int callbackOrder { get { return 1; } } + public void OnPostGenerateGradleAndroidProject(string path) { + Debug.Log(" UniWebView Post Build Scirpt is patching manifest file and gradle file..."); + PatchAndroidManifest(path); + PatchBuildGradle(path); + PatchGradleProperty(path); + } + + private void PatchAndroidManifest(string root) { + var manifestFilePath = GetManifestFilePath(root); + var manifest = new UniWebViewAndroidManifest(manifestFilePath); + + var changed = false; + + Debug.Log(" Set hardware accelerated to enable smooth web view experience and HTML5 support like video and canvas."); + changed = manifest.SetHardwareAccelerated() || changed; + + var settings = UniWebViewEditorSettings.GetOrCreateSettings(); + if (settings.usesCleartextTraffic) { + changed = manifest.SetUsesCleartextTraffic() || changed; + } + if (settings.writeExternalStorage) { + changed = manifest.AddWriteExternalStoragePermission() || changed; + } + if (settings.accessFineLocation) { + changed = manifest.AddAccessFineLocationPermission() || changed; + } + + if (changed) { + manifest.Save(); + } + } + + private void PatchBuildGradle(string root) { + var gradleFilePath = GetGradleFilePath(root); + var config = new UniWebViewGradleConfig(gradleFilePath); + + var kotlinPrefix = "implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:"; + var kotlinVersion = "1.4.31'"; + + var browserPrefix = "implementation 'androidx.browser:browser:"; + var browserVersion = "1.2.0'"; + + var settings = UniWebViewEditorSettings.GetOrCreateSettings(); + + var dependenciesNode = config.ROOT.FindChildNodeByName("dependencies"); + if (dependenciesNode != null) { + // Add kotlin + if (settings.addsKotlin) { + dependenciesNode.ReplaceContenOrAddStartsWith(kotlinPrefix, kotlinPrefix + kotlinVersion); + Debug.Log(" Updated Kotlin dependency in build.gradle."); + } + + // Add browser package + if (settings.addsAndroidBrowser) { + dependenciesNode.ReplaceContenOrAddStartsWith(browserPrefix, browserPrefix + browserVersion); + Debug.Log(" Updated Browser dependency in build.gradle."); + } + } else { + Debug.LogError("UniWebViewPostBuildProcessor didn't find the `dependencies` field in build.gradle."); + Debug.LogError("Although we can continue to add a `dependencies`, make sure you have setup Gradle and the template correctly."); + + var newNode = new UniWebViewGradleNode("dependencies", config.ROOT); + if (settings.addsKotlin) { + newNode.AppendContentNode(kotlinPrefix + kotlinVersion); + } + if (settings.addsAndroidBrowser) { + newNode.AppendContentNode(browserPrefix + browserVersion); + } + newNode.AppendContentNode("implementation(name: 'UniWebView', ext:'aar')"); + config.ROOT.AppendChildNode(newNode); + } + config.Save(); + } + + private void PatchGradleProperty(string root) { + var gradlePropertyFilePath = GetGradlePropertyFilePath(root); + UniWebViewGradlePropertyPatcher.Patch(gradlePropertyFilePath); + } + + private string CombinePaths(string[] paths) { + var path = ""; + foreach (var item in paths) { + path = Path.Combine(path, item); + } + return path; + } + + private string GetManifestFilePath(string root) { + string[] comps = {root, "src", "main", "AndroidManifest.xml"}; + return CombinePaths(comps); + } + + private string GetGradleFilePath(string root) { + string[] comps = {root, "build.gradle"}; + return CombinePaths(comps); + } + + private string GetGradlePropertyFilePath(string root) { + #if UNITY_2019_3_OR_NEWER + string[] compos = {root, "..", "gradle.properties"}; + #else + string[] compos = {root, "gradle.properties"}; + #endif + return CombinePaths(compos); + } +} \ No newline at end of file diff --git a/Assets/UniWebView/Editor/UniWebViewPostBuildProcessor.cs.meta b/Assets/UniWebView/Editor/UniWebViewPostBuildProcessor.cs.meta new file mode 100644 index 00000000..40665c71 --- /dev/null +++ b/Assets/UniWebView/Editor/UniWebViewPostBuildProcessor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 59d4a8d85c95843719d8b9df823c3da3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Interface.meta b/Assets/UniWebView/Interface.meta new file mode 100644 index 00000000..f50095ca --- /dev/null +++ b/Assets/UniWebView/Interface.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: dc0f52a2d219347b1a6390b753d6ac97 +folderAsset: yes +timeCreated: 1491898971 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Interface/UniWebViewAndroid.cs b/Assets/UniWebView/Interface/UniWebViewAndroid.cs new file mode 100644 index 00000000..844f5aaa --- /dev/null +++ b/Assets/UniWebView/Interface/UniWebViewAndroid.cs @@ -0,0 +1,402 @@ +#if UNITY_ANDROID && !UNITY_EDITOR + +using UnityEngine; + +public class UniWebViewInterface { + private static readonly AndroidJavaClass plugin; + private static bool correctPlatform = Application.platform == RuntimePlatform.Android; + + static UniWebViewInterface() { + var go = new GameObject("UniWebViewAndroidStaticListener"); + go.AddComponent(); + plugin = new AndroidJavaClass("com.onevcat.uniwebview.UniWebViewInterface"); + CheckPlatform(); + plugin.CallStatic("prepare"); + } + + public static void SetLogLevel(int level) { + CheckPlatform(); + plugin.CallStatic("setLogLevel", level); + } + + public static void Init(string name, int x, int y, int width, int height) { + CheckPlatform(); + plugin.CallStatic("init", name, x, y, width, height); + } + + public static void Destroy(string name) { + CheckPlatform(); + plugin.CallStatic("destroy", name); + } + + public static void Load(string name, string url, bool skipEncoding, string readAccessURL) { + CheckPlatform(); + plugin.CallStatic("load", name, url); + } + + public static void LoadHTMLString(string name, string html, string baseUrl, bool skipEncoding) { + CheckPlatform(); + plugin.CallStatic("loadHTMLString", name, html, baseUrl); + } + + public static void Reload(string name) { + CheckPlatform(); + plugin.CallStatic("reload", name); + } + + public static void Stop(string name) { + CheckPlatform(); + plugin.CallStatic("stop", name); + } + + public static string GetUrl(string name) { + CheckPlatform(); + return plugin.CallStatic("getUrl", name); + } + + public static void SetFrame(string name, int x, int y, int width, int height) { + CheckPlatform(); + plugin.CallStatic("setFrame", name, x, y, width, height); + } + + public static void SetPosition(string name, int x, int y) { + CheckPlatform(); + plugin.CallStatic("setPosition", name, x, y); + } + + public static void SetSize(string name, int width, int height) { + CheckPlatform(); + plugin.CallStatic("setSize", name, width, height); + } + + public static bool Show(string name, bool fade, int edge, float duration, bool useAsync, string identifier) { + CheckPlatform(); + if (useAsync) { + plugin.CallStatic("showAsync", name, fade, edge, duration, identifier); + return true; + } else { + return plugin.CallStatic("show", name, fade, edge, duration, identifier); + } + } + + public static bool Hide(string name, bool fade, int edge, float duration, bool useAsync, string identifier) { + CheckPlatform(); + if (useAsync) { + plugin.CallStatic("hideAsync", name, fade, edge, duration, identifier); + return true; + } else { + return plugin.CallStatic("hide", name, fade, edge, duration, identifier); + } + } + + public static bool AnimateTo(string name, int x, int y, int width, int height, float duration, float delay, string identifier) { + CheckPlatform(); + return plugin.CallStatic("animateTo", name, x, y, width, height, duration, delay, identifier); + } + + public static void AddJavaScript(string name, string jsString, string identifier) { + CheckPlatform(); + plugin.CallStatic("addJavaScript", name, jsString, identifier); + } + + public static void EvaluateJavaScript(string name, string jsString, string identifier) { + CheckPlatform(); + plugin.CallStatic("evaluateJavaScript", name, jsString, identifier); + } + + public static void AddUrlScheme(string name, string scheme) { + CheckPlatform(); + plugin.CallStatic("addUrlScheme", name, scheme); + } + + public static void RemoveUrlScheme(string name, string scheme) { + CheckPlatform(); + plugin.CallStatic("removeUrlScheme", name, scheme); + } + + public static void AddSslExceptionDomain(string name, string domain) { + CheckPlatform(); + plugin.CallStatic("addSslExceptionDomain", name, domain); + } + + public static void RemoveSslExceptionDomain(string name, string domain) { + CheckPlatform(); + plugin.CallStatic("removeSslExceptionDomain", name, domain); + } + + public static void AddPermissionTrustDomain(string name, string domain) { + CheckPlatform(); + plugin.CallStatic("addPermissionTrustDomain", name, domain); + } + + public static void RemovePermissionTrustDomain(string name, string domain) { + CheckPlatform(); + plugin.CallStatic("removePermissionTrustDomain", name, domain); + } + + public static void SetHeaderField(string name, string key, string value) { + CheckPlatform(); + plugin.CallStatic("setHeaderField", name, key, value); + } + + public static void SetUserAgent(string name, string userAgent) { + CheckPlatform(); + plugin.CallStatic("setUserAgent", name, userAgent); + } + + public static string GetUserAgent(string name) { + CheckPlatform(); + return plugin.CallStatic("getUserAgent", name); + } + + public static void SetAllowAutoPlay(bool flag) { + CheckPlatform(); + plugin.CallStatic("setAllowAutoPlay", flag); + } + + public static void SetAllowJavaScriptOpenWindow(bool flag) { + CheckPlatform(); + plugin.CallStatic("setAllowJavaScriptOpenWindow", flag); + } + + public static void SetAllowFileAccess(string name, bool flag) { + CheckPlatform(); + plugin.CallStatic("setAllowFileAccess", name, flag); + } + + public static void SetAllowFileAccessFromFileURLs(string name, bool flag) { + CheckPlatform(); + plugin.CallStatic("setAllowFileAccessFromFileURLs", name, flag); + } + + public static void SetAllowUniversalAccessFromFileURLs(bool flag) { + CheckPlatform(); + plugin.CallStatic("setAllowUniversalAccessFromFileURLs", flag); + } + + public static void SetEnableKeyboardAvoidance(bool flag) { + CheckPlatform(); + plugin.CallStatic("setEnableKeyboardAvoidance", flag); + } + + public static void SetJavaScriptEnabled(bool enabled) { + CheckPlatform(); + plugin.CallStatic("setJavaScriptEnabled", enabled); + } + + public static void CleanCache(string name) { + CheckPlatform(); + plugin.CallStatic("cleanCache", name); + } + + public static void ClearCookies() { + CheckPlatform(); + plugin.CallStatic("clearCookies"); + } + + public static void SetCookie(string url, string cookie, bool skipEncoding) { + CheckPlatform(); + plugin.CallStatic("setCookie", url, cookie); + } + + public static string GetCookie(string url, string key, bool skipEncoding) { + CheckPlatform(); + return plugin.CallStatic("getCookie", url, key); + } + + public static void RemoveCookies(string url, bool skipEncoding) { + CheckPlatform(); + plugin.CallStatic("removeCookies", url); + } + + public static void RemoveCookie(string url, string key, bool skipEncoding) { + CheckPlatform(); + plugin.CallStatic("removeCookie", url, key); + } + + public static void ClearHttpAuthUsernamePassword(string host, string realm) { + CheckPlatform(); + plugin.CallStatic("clearHttpAuthUsernamePassword", host, realm); + } + + public static void SetBackgroundColor(string name, float r, float g, float b, float a) { + CheckPlatform(); + plugin.CallStatic("setBackgroundColor", name, r, g, b, a); + } + + public static void SetWebViewAlpha(string name, float alpha) { + CheckPlatform(); + plugin.CallStatic("setWebViewAlpha", name, alpha); + } + + public static float GetWebViewAlpha(string name) { + CheckPlatform(); + return plugin.CallStatic("getWebViewAlpha", name); + } + + public static void SetShowSpinnerWhileLoading(string name, bool show) { + CheckPlatform(); + plugin.CallStatic("setShowSpinnerWhileLoading", name, show); + } + + public static void SetSpinnerText(string name, string text) { + CheckPlatform(); + plugin.CallStatic("setSpinnerText", name, text); + } + + public static bool CanGoBack(string name) { + CheckPlatform(); + return plugin.CallStatic("canGoBack", name); + } + + public static bool CanGoForward(string name) { + CheckPlatform(); + return plugin.CallStatic("canGoForward", name); + } + + public static void GoBack(string name) { + CheckPlatform(); + plugin.CallStatic("goBack", name); + } + public static void GoForward(string name) { + CheckPlatform(); + plugin.CallStatic("goForward", name); + } + + public static void SetOpenLinksInExternalBrowser(string name, bool flag) { + CheckPlatform(); + plugin.CallStatic("setOpenLinksInExternalBrowser", name, flag); + } + + public static void SetHorizontalScrollBarEnabled(string name, bool enabled) { + CheckPlatform(); + plugin.CallStatic("setHorizontalScrollBarEnabled", name, enabled); + } + + public static void SetVerticalScrollBarEnabled(string name, bool enabled) { + CheckPlatform(); + plugin.CallStatic("setVerticalScrollBarEnabled", name, enabled); + } + + public static void SetBouncesEnabled(string name, bool enabled) { + CheckPlatform(); + plugin.CallStatic("setBouncesEnabled", name, enabled); + } + + public static void SetZoomEnabled(string name, bool enabled) { + CheckPlatform(); + plugin.CallStatic("setZoomEnabled", name, enabled); + } + + public static void SetUseWideViewPort(string name, bool use) { + CheckPlatform(); + plugin.CallStatic("setUseWideViewPort", name, use); + } + + public static void SetLoadWithOverviewMode(string name, bool overview) { + CheckPlatform(); + plugin.CallStatic("setLoadWithOverviewMode", name, overview); + } + + public static void SetImmersiveModeEnabled(string name, bool enabled) { + CheckPlatform(); + plugin.CallStatic("setImmersiveModeEnabled", name, enabled); + } + + public static void SetUserInteractionEnabled(string name, bool enabled) { + CheckPlatform(); + plugin.CallStatic("setUserInteractionEnabled", name, enabled); + } + + public static void SetTransparencyClickingThroughEnabled(string name, bool enabled) { + CheckPlatform(); + plugin.CallStatic("setTransparencyClickingThroughEnabled", name, enabled); + } + + public static void SetWebContentsDebuggingEnabled(bool enabled) { + CheckPlatform(); + plugin.CallStatic("setWebContentsDebuggingEnabled", enabled); + } + + public static void SetAllowHTTPAuthPopUpWindow(string name, bool flag) { + CheckPlatform(); + plugin.CallStatic("setAllowHTTPAuthPopUpWindow", name, flag); + } + + public static void Print(string name) { + CheckPlatform(); + plugin.CallStatic("print", name); + } + + public static void CaptureSnapshot(string name, string filename) { + CheckPlatform(); + plugin.CallStatic("captureSnapshot", name, filename); + } + + public static void ScrollTo(string name, int x, int y, bool animated) { + CheckPlatform(); + plugin.CallStatic("scrollTo", name, x, y, animated); + } + + public static void SetCalloutEnabled(string name, bool flag) { + CheckPlatform(); + plugin.CallStatic("setCalloutEnabled", name, flag); + } + + public static void SetSupportMultipleWindows(string name, bool flag) { + CheckPlatform(); + plugin.CallStatic("setSupportMultipleWindows", name, flag); + } + + public static void SetDefaultFontSize(string name, int size) { + CheckPlatform(); + plugin.CallStatic("setDefaultFontSize", name, size); + } + + public static void SetTextZoom(string name, int textZoom) { + CheckPlatform(); + plugin.CallStatic("setTextZoom", name, textZoom); + } + + public static float NativeScreenWidth() { + CheckPlatform(); + return plugin.CallStatic("screenWidth"); + } + + public static float NativeScreenHeight() { + CheckPlatform(); + return plugin.CallStatic("screenHeight"); + } + + public static void SetDownloadEventForContextMenuEnabled(string name, bool enabled) { + CheckPlatform(); + plugin.CallStatic("setDownloadEventForContextMenuEnabled", name, enabled); + } + + public static bool IsSafeBrowsingSupported() { + CheckPlatform(); + return plugin.CallStatic("isSafeBrowsingSupported"); + } + + public static void SafeBrowsingInit(string name, string url) { + CheckPlatform(); + plugin.CallStatic("safeBrowsingInit", name, url); + } + + public static void SafeBrowsingSetToolbarColor(string name, float r, float g, float b) { + CheckPlatform(); + plugin.CallStatic("safeBrowsingSetToolbarColor", name, r, g, b); + } + + public static void SafeBrowsingShow(string name) { + CheckPlatform(); + plugin.CallStatic("safeBrowsingShow", name); + } + + public static void CheckPlatform() { + if (!correctPlatform) { + throw new System.InvalidOperationException("Method can only be performed on Android."); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/UniWebView/Interface/UniWebViewAndroid.cs.meta b/Assets/UniWebView/Interface/UniWebViewAndroid.cs.meta new file mode 100644 index 00000000..0066794f --- /dev/null +++ b/Assets/UniWebView/Interface/UniWebViewAndroid.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5a1d3cecc27d64565835e14b493c935b +timeCreated: 1490880130 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Interface/UniWebViewAndroidStaticListener.cs b/Assets/UniWebView/Interface/UniWebViewAndroidStaticListener.cs new file mode 100644 index 00000000..39c7751a --- /dev/null +++ b/Assets/UniWebView/Interface/UniWebViewAndroidStaticListener.cs @@ -0,0 +1,39 @@ + +// #if UNITY_ANDROID && !UNITY_EDITOR +using System; +using System.Reflection; +using UnityEngine; + +public class UniWebViewAndroidStaticListener: MonoBehaviour { + void Awake() { + DontDestroyOnLoad(gameObject); + } + + void OnJavaMessage(string message) { + // {listener_name}@{method_name}@parameters + string[] parts = message.Split("@"[0]); + if (parts.Length < 3) { + Debug.Log("Not enough parts for receiving a message."); + return; + } + + var listener = UniWebViewNativeListener.GetListener(parts[0]); + if (listener == null) { + return; + } + + MethodInfo methodInfo = typeof(UniWebViewNativeListener).GetMethod(parts[1]); + if (methodInfo == null) { + Debug.Log("Cannot find correct method to invoke: " + parts[1]); + } + + var leftLength = parts.Length - 2; + var left = new string[leftLength]; + for (int i = 0; i < leftLength; i++) { + left[i] = parts[i + 2]; + } + methodInfo.Invoke(listener, new object[] { String.Join("@", left) }); + } +} + +// #endif \ No newline at end of file diff --git a/Assets/UniWebView/Interface/UniWebViewAndroidStaticListener.cs.meta b/Assets/UniWebView/Interface/UniWebViewAndroidStaticListener.cs.meta new file mode 100644 index 00000000..407b0f93 --- /dev/null +++ b/Assets/UniWebView/Interface/UniWebViewAndroidStaticListener.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 2704cf8e127d541f1888d96429308645 +timeCreated: 1514387178 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Interface/UniWebViewCocoa.cs b/Assets/UniWebView/Interface/UniWebViewCocoa.cs new file mode 100644 index 00000000..065a0f20 --- /dev/null +++ b/Assets/UniWebView/Interface/UniWebViewCocoa.cs @@ -0,0 +1,687 @@ +// +// 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; + +public class UniWebViewInterface { + static UniWebViewInterface() { + ConnectMessageSender(); + } + + delegate void UnitySendMessageDelegate(IntPtr objectName, IntPtr methodName, IntPtr parameter); + + 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(SendMessage); + } + + [MonoPInvokeCallback(typeof(UnitySendMessageDelegate))] + private static void SendMessage(IntPtr namePtr, IntPtr methodPtr, IntPtr parameterPtr) { + 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 + ); + + var listener = UniWebViewNativeListener.GetListener(name); + if (listener) { + MethodInfo methodInfo = typeof(UniWebViewNativeListener).GetMethod(method); + if (methodInfo != null) { + methodInfo.Invoke(listener, new object[] { parameters }); + } + } + } + + [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 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)] + 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)] + 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_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); + 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); + public static void RemoveSslExceptionDomain(string name, string domain) { + CheckPlatform(); + uv_removeSslExceptionDomain(name, domain); + } + + [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_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_cleanCache(string name); + public static void CleanCache(string name) { + CheckPlatform(); + uv_cleanCache(name); + } + + [DllImport(DllLib)] + private static extern void uv_clearCookies(); + public static void ClearCookies() { + CheckPlatform(); + uv_clearCookies(); + } + + [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_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_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 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_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 bool uv_canGoBack(string name); + public static bool CanGoBack(string name) { + CheckPlatform(); + return uv_canGoBack(name); + } + + [DllImport(DllLib)] + 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_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_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_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); + } + + [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_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 flag); + public static void SetSupportMultipleWindows(string name, bool flag) { + CheckPlatform(); + uv_setSupportMultipleWindows(name, flag); + } + + [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_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); + } + + public static void CheckPlatform() { + if (!correctPlatform) { + throw new System.InvalidOperationException( + "Method can only be performed on correct platform. Current: " + Application.platform + ); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/UniWebView/Interface/UniWebViewCocoa.cs.meta b/Assets/UniWebView/Interface/UniWebViewCocoa.cs.meta new file mode 100644 index 00000000..af02b388 --- /dev/null +++ b/Assets/UniWebView/Interface/UniWebViewCocoa.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2e905ba0b47304f4cbf9e3e3345f84eb +timeCreated: 1492400358 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Interface/UniWebViewPlaceholder.cs b/Assets/UniWebView/Interface/UniWebViewPlaceholder.cs new file mode 100644 index 00000000..567e3fbd --- /dev/null +++ b/Assets/UniWebView/Interface/UniWebViewPlaceholder.cs @@ -0,0 +1,89 @@ +#if UNITY_EDITOR_WIN || UNITY_EDITOR_LINUX || (!UNITY_EDITOR_OSX && !UNITY_STANDALONE_OSX && !UNITY_IOS && !UNITY_ANDROID) + +using UnityEngine; + +public class UniWebViewInterface { + + private static bool alreadyLoggedWarning = false; + + public static void SetLogLevel(int level) { CheckPlatform(); } + public static void Init(string name, int x, int y, int width, int height) { CheckPlatform(); } + public static void Destroy(string name) { CheckPlatform(); } + public static void Load(string name, string url, bool skipEncoding, string readAccessURL) { CheckPlatform(); } + public static void LoadHTMLString(string name, string html, string baseUrl, bool skipEncoding) { CheckPlatform(); } + public static void Reload(string name) { CheckPlatform(); } + public static void Stop(string name) { CheckPlatform(); } + public static string GetUrl(string name) { CheckPlatform(); return ""; } + public static void SetFrame(string name, int x, int y, int width, int height) { CheckPlatform(); } + public static void SetPosition(string name, int x, int y) { CheckPlatform(); } + public static void SetSize(string name, int width, int height) { CheckPlatform(); } + public static bool Show(string name, bool fade, int edge, float duration, bool useAsync, string identifier) { CheckPlatform(); return false; } + public static bool Hide(string name, bool fade, int edge, float duration, bool useAsync, string identifier) { CheckPlatform(); return false; } + public static bool AnimateTo(string name, int x, int y, int width, int height, float duration, float delay, string identifier) { CheckPlatform(); return false; } + public static void AddJavaScript(string name, string jsString, string identifier) { CheckPlatform(); } + public static void EvaluateJavaScript(string name, string jsString, string identifier) { CheckPlatform(); } + public static void AddUrlScheme(string name, string scheme) { CheckPlatform(); } + public static void RemoveUrlScheme(string name, string scheme) { CheckPlatform(); } + public static void AddSslExceptionDomain(string name, string domain) { CheckPlatform(); } + public static void RemoveSslExceptionDomain(string name, string domain) { CheckPlatform(); } + public static void SetHeaderField(string name, string key, string value) { CheckPlatform(); } + public static void SetUserAgent(string name, string userAgent) { CheckPlatform(); } + public static string GetUserAgent(string name) { CheckPlatform(); return ""; } + public static void SetAllowAutoPlay(bool flag) { CheckPlatform(); } + public static void SetAllowInlinePlay(bool flag) { CheckPlatform(); } + public static void SetAllowJavaScriptOpenWindow(bool flag) { CheckPlatform(); } + public static void SetAllowFileAccess(string name, bool flag) { CheckPlatform(); } + public static void SetAllowFileAccessFromFileURLs(string name, bool flag) { CheckPlatform(); } + public static void SetAllowUniversalAccessFromFileURLs(bool flag) { CheckPlatform(); } + public static void SetJavaScriptEnabled(bool flag) { CheckPlatform(); } + public static void CleanCache(string name) { CheckPlatform(); } + public static void ClearCookies() { CheckPlatform(); } + public static void SetCookie(string url, string cookie, bool skipEncoding) { CheckPlatform(); } + public static void RemoveCookies(string url, bool skipEncoding) { CheckPlatform(); } + public static void RemoveCookie(string url, string key, bool skipEncoding) { CheckPlatform(); } + public static string GetCookie(string url, string key, bool skipEncoding) { CheckPlatform(); return ""; } + public static void ClearHttpAuthUsernamePassword(string host, string realm) { CheckPlatform(); } + public static void SetBackgroundColor(string name, float r, float g, float b, float a) { CheckPlatform(); } + public static void SetWebViewAlpha(string name, float alpha) { CheckPlatform(); } + public static float GetWebViewAlpha(string name) { CheckPlatform(); return 0.0f; } + public static void SetShowSpinnerWhileLoading(string name, bool show) { CheckPlatform(); } + public static void SetSpinnerText(string name, string text) { CheckPlatform(); } + public static bool CanGoBack(string name) { CheckPlatform(); return false; } + public static bool CanGoForward(string name) { CheckPlatform(); return false; } + public static void GoBack(string name) { CheckPlatform(); } + public static void GoForward(string name) { CheckPlatform(); } + public static void SetOpenLinksInExternalBrowser(string name, bool flag) { CheckPlatform(); } + public static void SetHorizontalScrollBarEnabled(string name, bool enabled) { CheckPlatform(); } + public static void SetVerticalScrollBarEnabled(string name, bool enabled) { CheckPlatform(); } + public static void SetBouncesEnabled(string name, bool enabled) { CheckPlatform(); } + public static void SetZoomEnabled(string name, bool enabled) { CheckPlatform(); } + public static void SetShowToolbar(string name, bool show, bool animated, bool onTop, bool adjustInset) { CheckPlatform(); } + public static void SetToolbarDoneButtonText(string name, string text) { CheckPlatform(); } + public static void SetToolbarGoBackButtonText(string name, string text) { CheckPlatform(); } + public static void SetToolbarGoForwardButtonText(string name, string text) { CheckPlatform(); } + public static void SetToolbarTintColor(string name, float r, float g, float b) { CheckPlatform(); } + public static void SetToolbarTextColor(string name, float r, float g, float b) { CheckPlatform(); } + public static void SetUserInteractionEnabled(string name, bool enabled) { CheckPlatform(); } + public static void SetTransparencyClickingThroughEnabled(string name, bool enabled) { CheckPlatform(); } + public static void SetWebContentsDebuggingEnabled(bool enabled) { CheckPlatform(); } + public static void SetAllowHTTPAuthPopUpWindow(string name, bool flag) { CheckPlatform(); } + public static void Print(string name) { CheckPlatform(); } + public static void CaptureSnapshot(string name, string filename) { CheckPlatform(); } + public static void SetCalloutEnabled(string name, bool flag) { CheckPlatform(); } + public static void SetSupportMultipleWindows(string name, bool flag) { CheckPlatform(); } + public static void SetDragInteractionEnabled(string name, bool flag) { CheckPlatform(); } + public static void ScrollTo(string name, int x, int y, bool animated) { CheckPlatform(); } + public static float NativeScreenWidth() { CheckPlatform(); return 0.0f; } + public static float NativeScreenHeight() { CheckPlatform(); return 0.0f; } + public static void SafeBrowsingInit(string name, string url) { CheckPlatform(); } + public static void SafeBrowsingSetToolbarColor(string name, float r, float g, float b) { CheckPlatform(); } + public static void SafeBrowsingShow(string name) { CheckPlatform(); } + + public static void CheckPlatform() { + if (!alreadyLoggedWarning) { + alreadyLoggedWarning = true; + Debug.LogWarning("UniWebView only supports iOS/Android/macOS Editor. You current platform " + Application.platform + " is not supported."); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/UniWebView/Interface/UniWebViewPlaceholder.cs.meta b/Assets/UniWebView/Interface/UniWebViewPlaceholder.cs.meta new file mode 100644 index 00000000..a99c0465 --- /dev/null +++ b/Assets/UniWebView/Interface/UniWebViewPlaceholder.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0b3bad20d12b1433ab8927c3effc605b +timeCreated: 1497403102 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Prefab.meta b/Assets/UniWebView/Prefab.meta new file mode 100644 index 00000000..c6b458a0 --- /dev/null +++ b/Assets/UniWebView/Prefab.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: d5d657f2ee1114e20bccaace74235a99 +folderAsset: yes +timeCreated: 1491898971 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Prefab/UniWebView.prefab b/Assets/UniWebView/Prefab/UniWebView.prefab new file mode 100644 index 00000000..98afb506 --- /dev/null +++ b/Assets/UniWebView/Prefab/UniWebView.prefab @@ -0,0 +1,57 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &1900085666445226 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4960404783511462} + - component: {fileID: 114939446366399424} + m_Layer: 0 + m_Name: UniWebView + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4960404783511462 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1900085666445226} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &114939446366399424 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1900085666445226} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 598e18fb001004a81960f552978ecf4e, type: 3} + m_Name: + m_EditorClassIdentifier: + urlOnStart: + showOnStart: 1 + fullScreen: 1 + useToolbar: 1 + toolbarPosition: 0 + frame: + serializedVersion: 2 + x: 0 + y: 0 + width: 0 + height: 0 + referenceRectTransform: {fileID: 0} diff --git a/Assets/UniWebView/Prefab/UniWebView.prefab.meta b/Assets/UniWebView/Prefab/UniWebView.prefab.meta new file mode 100644 index 00000000..063115af --- /dev/null +++ b/Assets/UniWebView/Prefab/UniWebView.prefab.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 7e3f16a6f6303419cbd9837f6c746de4 +timeCreated: 1496204510 +licenseType: Store +NativeFormatImporter: + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Prefab/UniWebViewSafeBrowsing.prefab b/Assets/UniWebView/Prefab/UniWebViewSafeBrowsing.prefab new file mode 100644 index 00000000..08e434fd --- /dev/null +++ b/Assets/UniWebView/Prefab/UniWebViewSafeBrowsing.prefab @@ -0,0 +1,46 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &8236771505572270655 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8236771505572270653} + - component: {fileID: 8236771505572270654} + m_Layer: 0 + m_Name: UniWebViewSafeBrowsing + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &8236771505572270653 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8236771505572270655} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &8236771505572270654 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8236771505572270655} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5843488507315421aa0a7d92c0604d10, type: 3} + m_Name: + m_EditorClassIdentifier: + url: diff --git a/Assets/UniWebView/Prefab/UniWebViewSafeBrowsing.prefab.meta b/Assets/UniWebView/Prefab/UniWebViewSafeBrowsing.prefab.meta new file mode 100644 index 00000000..145400e7 --- /dev/null +++ b/Assets/UniWebView/Prefab/UniWebViewSafeBrowsing.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 2d6c4899a63004f16bb4f791176f4ad3 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/README.txt b/Assets/UniWebView/README.txt new file mode 100644 index 00000000..09281fb5 --- /dev/null +++ b/Assets/UniWebView/README.txt @@ -0,0 +1,30 @@ +# UniWebView + +Thank you for purchasing UniWebView. + +UniWebView is a Unity3D plugin built on native iOS/Android technology. It helps your users to enjoy web content and +interact with your game through the web views. + +## Documentation + +To get started, please visit our documentation site: [https://docs.uniwebview.com](https://docs.uniwebview.com). You +could find step-by-step guides on how to import UniWebView to your project, as well as some basic usage of this asset. +You could also find a full script reference on the same site in this page: [https://docs.uniwebview.com/api/](https://docs.uniwebview.com/api/). + +## Upgrading + +All purchased customers could get all updates for the same major version for free. Please check the place you have +purchased this asset to see whether there is an update or not. A release note is also contained in this asset, in the +"CHANGELOG.md" file. You could also find the same version list in [this page](https://docs.uniwebview.com/release-note). + +## Getting Support + +For frequently asked questions, we have a page to answer them. If you encountered any problems while using UniWebView, +we strongly suggest to visit the [FAQ page](https://docs.uniwebview.com/guide/faq.html) first. Also feel free to +[submit a ticket](https://onevcat.atlassian.net/servicedesk/customer/portal/2) if you cannot find a solution, we will +do our best to get you out! + +## Other + +For more information, please visit the [official web site](https://uniwebview.com) of UniWebView, or contact us through +a ticket. diff --git a/Assets/UniWebView/README.txt.meta b/Assets/UniWebView/README.txt.meta new file mode 100644 index 00000000..b30fbfcc --- /dev/null +++ b/Assets/UniWebView/README.txt.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 95440ce70c5e14d6e96e166c45f7cf6d +timeCreated: 1499302025 +licenseType: Store +TextScriptImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Script.meta b/Assets/UniWebView/Script.meta new file mode 100644 index 00000000..c78c9fe8 --- /dev/null +++ b/Assets/UniWebView/Script.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: b34f36f9836464e04893f632434d0862 +folderAsset: yes +timeCreated: 1491898971 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Script/UniWebView.cs b/Assets/UniWebView/Script/UniWebView.cs new file mode 100644 index 00000000..6763d5ea --- /dev/null +++ b/Assets/UniWebView/Script/UniWebView.cs @@ -0,0 +1,1739 @@ +// +// UniWebView.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. +// +using UnityEngine; +using System.Collections; +using System.Collections.Generic; +using System; + +/// +/// Main class of UniWebView. Any `GameObject` instance with this script can represent a webview object in the scene. +/// Use this class to create, load, show and interact with a general-purpose web view. +/// +public class UniWebView: MonoBehaviour { + /// + /// Delegate for page started event. + /// + /// The web view component which raises this event. + /// The url which the web view is about to load. + public delegate void PageStartedDelegate(UniWebView webView, string url); + + /// + /// Raised when the web view starts loading a url. + /// + /// This event will be invoked for both url loading with `Load` method or by a link navigating from page. + /// + public event PageStartedDelegate OnPageStarted; + + /// + /// Delegate for page finished event. + /// + /// The web view component which raises this event. + /// HTTP status code received from response. + /// The url which the web view loaded. + public delegate void PageFinishedDelegate(UniWebView webView, int statusCode, string url); + /// + /// Raised when the web view finished to load a url successfully. + /// + /// This method will be invoked when a valid response received from the url, regardless of the response status. + /// If a url loading fails before reaching to the server and getting a response, `OnPageErrorReceived` will be + /// raised instead. + /// + public event PageFinishedDelegate OnPageFinished; + + /// + /// Delegate for page error received event. + /// + /// The web view component which raises this event. + /// + /// The error code which indicates the error type. + /// It can be different from systems and platforms. + /// + /// The error message which indicates the error. + public delegate void PageErrorReceivedDelegate(UniWebView webView, int errorCode, string errorMessage); + /// + /// Raised when an error encountered during the loading process. + /// Such as the "host not found" error or "no Internet connection" error will raise this event. + /// + public event PageErrorReceivedDelegate OnPageErrorReceived; + + /// + /// Delegate for page progress changed event. + /// + /// The web view component which raises this event. + /// A value indicates the loading progress of current page. It is a value between 0.0f and 1.0f. + public delegate void PageProgressChangedDelegate(UniWebView webView, float progress); + /// + /// Raised when the loading progress value changes in current web view. + /// + public event PageProgressChangedDelegate OnPageProgressChanged; + + /// + /// Delegate for message received event. + /// + /// The web view component which raises this event. + /// Message received from web view. + public delegate void MessageReceivedDelegate(UniWebView webView, UniWebViewMessage message); + /// + /// Raised when a message from web view is received. + /// + /// Generally, the message comes from a navigation to + /// a scheme which is observed by current web view. You could use `AddUrlScheme` and + /// `RemoveUrlScheme` to manipulate the scheme list. + /// + /// "uniwebview://" scheme is default in the list, so a clicking on link starting with "uniwebview://" + /// will raise this event, if it is not removed. + /// + public event MessageReceivedDelegate OnMessageReceived; + + /// + /// Delegate for should close event. + /// + /// The web view component which raises this event. + /// Whether the web view should be closed and destroyed. + public delegate bool ShouldCloseDelegate(UniWebView webView); + /// + /// Raised when the web view is about to close itself. + /// + /// This event is raised when the users close the web view by Back button on Android, Done button on iOS, + /// or Close button on Unity Editor. It gives a chance to make final decision whether the web view should + /// be closed and destroyed. You can also clean all related resources you created (such as a reference to + /// the web view) in this event. + /// + public event ShouldCloseDelegate OnShouldClose; + + /// + /// Delegate for orientation changed event. + /// + /// The web view component which raises this event. + /// The screen orientation for current state. + public delegate void OrientationChangedDelegate(UniWebView webView, ScreenOrientation orientation); + /// + /// Raised when the screen orientation is changed. It is a good time to set the web view frame if you + /// need to support multiple orientations in your game. + /// + public event OrientationChangedDelegate OnOrientationChanged; + + /// + /// Delegate for content loading terminated event. + /// + /// The web view component which raises this event. + public delegate void OnWebContentProcessTerminatedDelegate(UniWebView webView); + /// + /// Raised when on iOS, when system calls `webViewWebContentProcessDidTerminate` method. + /// It is usually due to a low memory when loading the web content and leave you a blank white screen. + /// You need to free as much as memory you could and then do a page reload. + /// + public event OnWebContentProcessTerminatedDelegate OnWebContentProcessTerminated; + + /// + /// Delegate for file download task starting event. + /// + /// The web view component which raises this event. + /// The remote URL of this download task. This is also the download URL for the task. + /// The file name which user chooses to use. + public delegate void FileDownloadStarted(UniWebView webView, string remoteUrl, string fileName); + /// + /// Raised when a file download task starts. + /// + public event FileDownloadStarted OnFileDownloadStarted; + + /// + /// Delegate for file download task finishing event. + /// + /// The web view component which raises this event. + /// + /// The error code of the download task result. Value `0` means the download finishes without a problem. + /// Any other non-`0` value indicates an issue. The detail meaning of the error code depends on system. + /// On iOS, it is usually the `errorCode` of the received `NSURLError`. On Android, the value usually represents + /// an `ERROR_*` value in `DownloadManager`. + /// + /// The remote URL of this download task. + /// + /// The file path of the downloaded file. On iOS, the downloader file is in a temporary folder of your app sandbox. + /// On Android, it is in the "Download" folder of your app. + /// + public delegate void FileDownloadFinished(UniWebView webView, int errorCode, string remoteUrl, string diskPath); + /// + /// Raised when a file download task finishes with either an error or success. + /// + public event FileDownloadFinished OnFileDownloadFinished; + + /// + /// Delegate for capturing snapshot finished event. + /// + /// The web view component which raises this event. + /// + /// The error code of the event. If the snapshot is captured and stored without a problem, the error code is 0. + /// Any other number indicates an error happened. In most cases, the screenshot capturing only fails due to lack + /// of disk storage. + /// + /// + /// An accessible disk path to the captured snapshot image. If an error happens, it is an empty string. + /// + public delegate void CaptureSnapshotFinished(UniWebView webView, int errorCode, string diskPath); + /// + /// Raised when an image captured and stored in a cache path on disk. + /// + public event CaptureSnapshotFinished OnCaptureSnapshotFinished; + + /// + /// Delegate for multiple window opening event. + /// + /// The web view component which opens the new multiple (pop-up) window. + /// The identifier of the opened new window. + public delegate void MultipleWindowOpenedDelegate(UniWebView webView, string multipleWindowId); + /// + /// Raised when a new window is opened. This happens when you enable the `SetSupportMultipleWindows` and open a + /// new pop-up window. + /// + public event MultipleWindowOpenedDelegate OnMultipleWindowOpened; + + /// + /// Delegate for multiple window closing event. + /// + /// The web view component which closes the multiple window. + /// The identifier of the closed window. + public delegate void MultipleWindowClosedDelegate(UniWebView webView, string multipleWindowId); + /// + /// Raised when the multiple window is closed. This happens when the pop-up window is closed by navigation operation + /// or by a invocation of `close()` on the page. + /// + public event MultipleWindowClosedDelegate OnMultipleWindowClosed; + + private string id = Guid.NewGuid().ToString(); + private UniWebViewNativeListener listener; + + private bool isPortrait; + [SerializeField] + + #pragma warning disable 0649 + private string urlOnStart; + [SerializeField] + private bool showOnStart = false; + + [SerializeField] + private bool fullScreen; + + [SerializeField] + private bool useToolbar; + + + [SerializeField] + private UniWebViewToolbarPosition toolbarPosition; + + #pragma warning restore 0649 + + // Action callback holders + private Dictionary actions = new Dictionary(); + private Dictionary> payloadActions = new Dictionary>(); + + [SerializeField] + private Rect frame; + /// + /// Gets or sets the frame of current web view. The value is based on current `Screen.width` and `Screen.height`. + /// The first two values of `Rect` is `x` and `y` position and the followed two `width` and `height`. + /// + public Rect Frame { + get { return frame; } + set { + frame = value; + UpdateFrame(); + } + } + + [SerializeField] + private RectTransform referenceRectTransform; + /// + /// A reference rect transform which the web view should change its position and size to. + /// Set it to a Unity UI element (which contains a `RectTransform`) under a canvas to determine + /// the web view frame by a certain UI element. + /// + /// By using this, you could get benefit from [Multiple Resolutions UI](https://docs.unity3d.com/Manual/HOWTO-UIMultiResolution.html). + /// + /// + public RectTransform ReferenceRectTransform { + get { + return referenceRectTransform; + } + set { + referenceRectTransform = value; + UpdateFrame(); + } + } + + private bool started; + + private bool backButtonEnabled = true; + + /// + /// The url of current loaded web page. + /// + public string Url { + get { return UniWebViewInterface.GetUrl(listener.Name); } + } + + /// + /// Updates and sets current frame of web view to match the setting. + /// + /// This is useful if the `referenceRectTransform` is changed and you need to sync the frame change + /// to the web view. This method follows the frame determining rules. + /// + public void UpdateFrame() { + Rect rect = NextFrameRect(); + UniWebViewInterface.SetFrame(listener.Name, (int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height); + } + + Rect NextFrameRect() { + if (referenceRectTransform == null) { + UniWebViewLogger.Instance.Info("Using Frame setting to determine web view frame."); + return frame; + } else { + UniWebViewLogger.Instance.Info("Using reference RectTransform to determine web view frame."); + var worldCorners = new Vector3[4]; + + referenceRectTransform.GetWorldCorners(worldCorners); + + var bottomLeft = worldCorners[0]; + var topLeft = worldCorners[1]; + var topRight = worldCorners[2]; + var bottomRight = worldCorners[3]; + + var canvas = referenceRectTransform.GetComponentInParent(); + if (canvas == null) { + return frame; + } + + switch (canvas.renderMode) { + case RenderMode.ScreenSpaceOverlay: + break; + case RenderMode.ScreenSpaceCamera: + case RenderMode.WorldSpace: + var camera = canvas.worldCamera; + if (camera == null) { + UniWebViewLogger.Instance.Critical(@"You need a render camera + or event camera to use RectTransform to determine correct + frame for UniWebView."); + UniWebViewLogger.Instance.Info("No camera found. Fall back to ScreenSpaceOverlay mode."); + } else { + bottomLeft = camera.WorldToScreenPoint(bottomLeft); + topLeft = camera.WorldToScreenPoint(topLeft); + topRight = camera.WorldToScreenPoint(topRight); + bottomRight = camera.WorldToScreenPoint(bottomRight); + } + break; + } + + float widthFactor = (float)UniWebViewInterface.NativeScreenWidth() / (float)Screen.width; + float heightFactor = (float)UniWebViewInterface.NativeScreenHeight() / (float)Screen.height; + + float x = topLeft.x * widthFactor; + float y = (Screen.height - topLeft.y) * heightFactor; + float width = (bottomRight.x - topLeft.x) * widthFactor; + float height = (topLeft.y - bottomRight.y) * heightFactor; + return new Rect(x, y, width, height); + } + } + + void Awake() { + var listenerObject = new GameObject(id); + listener = listenerObject.AddComponent(); + listenerObject.transform.parent = transform; + listener.webView = this; + UniWebViewNativeListener.AddListener(listener); + + Rect rect; + if (fullScreen) { + rect = new Rect(0, 0, Screen.width, Screen.height); + } else { + rect = NextFrameRect(); + } + + UniWebViewInterface.Init(listener.Name, (int)rect.x, (int)rect. y, (int)rect.width, (int)rect.height); + isPortrait = Screen.height >= Screen.width; + } + + void Start() { + if (showOnStart) { + Show(); + } + if (!string.IsNullOrEmpty(urlOnStart)) { + Load(urlOnStart); + } + started = true; + if (referenceRectTransform != null) { + UpdateFrame(); + } + } + + void Update() { + var newIsPortrait = Screen.height >= Screen.width; + if (isPortrait != newIsPortrait) { + isPortrait = newIsPortrait; + if (OnOrientationChanged != null) { + OnOrientationChanged(this, Screen.orientation); + } + if (referenceRectTransform != null) { + UpdateFrame(); + } + } + + if (backButtonEnabled && Input.GetKeyUp(KeyCode.Escape)) { + UniWebViewLogger.Instance.Info("Received Back button, handling GoBack or close web view."); + if (CanGoBack) { + GoBack(); + } else { + InternalOnShouldClose(); + } + } + } + + void OnEnable() { + if (started) { + _Show(useAsync: true); + } + } + + void OnDisable() { + if (started) { + _Hide(useAsync: true); + } + } + + /// + /// Loads a url in current web view. + /// + /// The url to be loaded. This url should start with `http://` or `https://` scheme. You could even load a non-ascii url text if it is valid. + /// + /// Whether UniWebView should skip encoding the url or not. If set to `false`, UniWebView will try to encode the url parameter before + /// loading it. Otherwise, your original url string will be used as the url if it is valid. Default is `false`. + /// + /// + /// The URL to allow read access to. This parameter is only used when loading from the filesystem in iOS, and passed + /// to `loadFileURL:allowingReadAccessToURL:` method of WebKit. By default, the parent folder of the `url` parameter will be read accessible. + /// + public void Load(string url, bool skipEncoding = false, string readAccessURL = null) { + UniWebViewInterface.Load(listener.Name, url, skipEncoding, readAccessURL); + } + + /// + /// Loads an HTML string in current web view. + /// + /// The HTML string to use as the contents of the webpage. + /// The url to use as the page's base url. + /// + /// Whether UniWebView should skip encoding the baseUrl or not. If set to `false`, UniWebView will try to encode the baseUrl parameter before + /// using it. Otherwise, your original url string will be used as the baseUrl if it is valid. Default is `false`. + /// + public void LoadHTMLString(string htmlString, string baseUrl, bool skipEncoding = false) { + UniWebViewInterface.LoadHTMLString(listener.Name, htmlString, baseUrl, skipEncoding); + } + + /// + /// Reloads the current page. + /// + public void Reload() { + UniWebViewInterface.Reload(listener.Name); + } + + /// + /// Stops loading all resources on the current page. + /// + public void Stop() { + UniWebViewInterface.Stop(listener.Name); + } + + /// + /// Gets whether there is a back page in the back-forward list that can be navigated to. + /// + public bool CanGoBack { + get { + return UniWebViewInterface.CanGoBack(listener.Name); + } + } + + /// + /// Gets whether there is a forward page in the back-forward list that can be navigated to. + /// + public bool CanGoForward { + get { + return UniWebViewInterface.CanGoForward(listener.Name); + } + } + + /// + /// Navigates to the back item in the back-forward list. + /// + public void GoBack() { + UniWebViewInterface.GoBack(listener.Name); + } + + /// + /// Navigates to the forward item in the back-forward list. + /// + public void GoForward() { + UniWebViewInterface.GoForward(listener.Name); + } + + /// + /// Sets whether the link clicking in the web view should open the page in an external browser. + /// + /// The flag indicates whether a link should be opened externally. + public void SetOpenLinksInExternalBrowser(bool flag) { + UniWebViewInterface.SetOpenLinksInExternalBrowser(listener.Name, flag); + } + + /// + /// Sets the web view visible on screen. + /// + /// If you pass `false` and `UniWebViewTransitionEdge.None` to the first two parameters, it means no animation will + /// be applied when showing. So the `duration` parameter will not be taken into account. Otherwise, when + /// either or both `fade` and `edge` set, the showing operation will be animated. + /// + /// Regardless of there is an animation or not, the `completionHandler` will be called if not `null` when the web + /// view showing finishes. + /// + /// Whether show with a fade in animation. Default is `false`. + /// The edge from which the web view showing. It simulates a modal effect when showing a web view. Default is `UniWebViewTransitionEdge.None`. + /// Duration of the showing animation. Default is `0.4f`. + /// Completion handler which will be called when showing finishes. Default is `null`. + /// A bool value indicates whether the showing operation started. + public bool Show(bool fade = false, UniWebViewTransitionEdge edge = UniWebViewTransitionEdge.None, + float duration = 0.4f, Action completionHandler = null) + { + return _Show(fade, edge, duration, false, completionHandler); + } + + private bool _Show(bool fade = false, UniWebViewTransitionEdge edge = UniWebViewTransitionEdge.None, + float duration = 0.4f, bool useAsync = false, Action completionHandler = null) + { + var identifier = Guid.NewGuid().ToString(); + var showStarted = UniWebViewInterface.Show(listener.Name, fade, (int)edge, duration, useAsync, identifier); + if (showStarted && completionHandler != null) { + var hasAnimation = (fade || edge != UniWebViewTransitionEdge.None); + if (hasAnimation) { + actions.Add(identifier, completionHandler); + } else { + completionHandler(); + } + } + if (showStarted && useToolbar) { + var top = (toolbarPosition == UniWebViewToolbarPosition.Top); + SetShowToolbar(true, false, top, fullScreen); + } + return showStarted; + } + + /// + /// Sets the web view invisible from screen. + /// + /// If you pass `false` and `UniWebViewTransitionEdge.None` to the first two parameters, it means no animation will + /// be applied when hiding. So the `duration` parameter will not be taken into account. Otherwise, when either or + /// both `fade` and `edge` set, the hiding operation will be animated. + /// + /// Regardless there is an animation or not, the `completionHandler` will be called if not `null` when the web view + /// hiding finishes. + /// + /// Whether hide with a fade in animation. Default is `false`. + /// The edge from which the web view hiding. It simulates a modal effect when hiding a web view. Default is `UniWebViewTransitionEdge.None`. + /// Duration of hiding animation. Default is `0.4f`. + /// Completion handler which will be called when hiding finishes. Default is `null`. + /// A bool value indicates whether the hiding operation started. + public bool Hide(bool fade = false, UniWebViewTransitionEdge edge = UniWebViewTransitionEdge.None, + float duration = 0.4f, Action completionHandler = null) + { + return _Hide(fade, edge, duration, false, completionHandler); + } + + public bool _Hide(bool fade = false, UniWebViewTransitionEdge edge = UniWebViewTransitionEdge.None, + float duration = 0.4f, bool useAsync = false, Action completionHandler = null) + { + var identifier = Guid.NewGuid().ToString(); + var hideStarted = UniWebViewInterface.Hide(listener.Name, fade, (int)edge, duration, useAsync, identifier); + if (hideStarted && completionHandler != null) { + var hasAnimation = (fade || edge != UniWebViewTransitionEdge.None); + if (hasAnimation) { + actions.Add(identifier, completionHandler); + } else { + completionHandler(); + } + } + if (hideStarted && useToolbar) { + var top = (toolbarPosition == UniWebViewToolbarPosition.Top); + SetShowToolbar(false, false, top, fullScreen); + } + return hideStarted; + } + + /// + /// Animates the web view from current position and size to another position and size. + /// + /// The new `Frame` which the web view should be. + /// Duration of the animation. + /// Delay before the animation begins. Default is `0.0f`, which means the animation will start immediately. + /// Completion handler which will be called when animation finishes. Default is `null`. + /// + public bool AnimateTo(Rect frame, float duration, float delay = 0.0f, Action completionHandler = null) { + var identifier = Guid.NewGuid().ToString(); + var animationStarted = UniWebViewInterface.AnimateTo(listener.Name, + (int)frame.x, (int)frame.y, (int)frame.width, (int)frame.height, duration, delay, identifier); + if (animationStarted) { + this.frame = frame; + if (completionHandler != null) { + actions.Add(identifier, completionHandler); + } + } + return animationStarted; + } + + /// + /// Adds a JavaScript to current page. + /// + /// The JavaScript code to add. It should be a valid JavaScript statement string. + /// Called when adding JavaScript operation finishes. Default is `null`. + public void AddJavaScript(string jsString, Action completionHandler = null) { + var identifier = Guid.NewGuid().ToString(); + UniWebViewInterface.AddJavaScript(listener.Name, jsString, identifier); + if (completionHandler != null) { + payloadActions.Add(identifier, completionHandler); + } + } + + /// + /// Evaluates a JavaScript string on current page. + /// + /// The JavaScript string to evaluate. + /// Called when evaluating JavaScript operation finishes. Default is `null`. + public void EvaluateJavaScript(string jsString, Action completionHandler = null) { + var identifier = Guid.NewGuid().ToString(); + UniWebViewInterface.EvaluateJavaScript(listener.Name, jsString, identifier); + if (completionHandler != null) { + payloadActions.Add(identifier, completionHandler); + } + } + + /// + /// Adds a url scheme to UniWebView message system interpreter. + /// All following url navigation to this scheme will be sent as a message to UniWebView instead. + /// + /// The url scheme to add. It should not contain "://" part. You could even add "http" and/or + /// "https" to prevent all resource loading on the page. "uniwebview" is added by default. Nothing will happen if + /// you try to add a duplicated scheme. + public void AddUrlScheme(string scheme) { + if (scheme == null) { + UniWebViewLogger.Instance.Critical("The scheme should not be null."); + return; + } + + if (scheme.Contains("://")) { + UniWebViewLogger.Instance.Critical("The scheme should not include invalid characters '://'"); + return; + } + UniWebViewInterface.AddUrlScheme(listener.Name, scheme); + } + + /// + /// Removes a url scheme from UniWebView message system interpreter. + /// + /// The url scheme to remove. Nothing will happen if the scheme is not in the message system. + public void RemoveUrlScheme(string scheme) { + if (scheme == null) { + UniWebViewLogger.Instance.Critical("The scheme should not be null."); + return; + } + if (scheme.Contains("://")) { + UniWebViewLogger.Instance.Critical("The scheme should not include invalid characters '://'"); + return; + } + UniWebViewInterface.RemoveUrlScheme(listener.Name, scheme); + } + + /// + /// Adds a domain to the SSL checking white list. + /// If you are trying to access a web site with untrusted or expired certification, + /// the web view will prevent its loading. If you could confirm that this site is trusted, + /// you can add the domain as an SSL exception, so you could visit it. + /// + /// The domain to add. It should not contain any scheme or path part in url. + public void AddSslExceptionDomain(string domain) { + if (domain == null) { + UniWebViewLogger.Instance.Critical("The domain should not be null."); + return; + } + if (domain.Contains("://")) { + UniWebViewLogger.Instance.Critical("The domain should not include invalid characters '://'"); + return; + } + UniWebViewInterface.AddSslExceptionDomain(listener.Name, domain); + } + + /// + /// Removes a domain from the SSL checking white list. + /// + /// The domain to remove. It should not contain any scheme or path part in url. + public void RemoveSslExceptionDomain(string domain) { + if (domain == null) { + UniWebViewLogger.Instance.Critical("The domain should not be null."); + return; + } + if (domain.Contains("://")) { + UniWebViewLogger.Instance.Critical("The domain should not include invalid characters '://'"); + return; + } + UniWebViewInterface.RemoveSslExceptionDomain(listener.Name, domain); + } + + /// + /// Sets a customized header field for web view requests. + /// + /// The header field will be used for all subsequence request. + /// Pass `null` as value to unset a header field. + /// + /// Some reserved headers like user agent are not be able to override by setting here, + /// use the `SetUserAgent` method for them instead. + /// + /// The key of customized header field. + /// The value of customized header field. `null` if you want to unset the field. + public void SetHeaderField(string key, string value) { + if (key == null) { + UniWebViewLogger.Instance.Critical("Header key should not be null."); + return; + } + UniWebViewInterface.SetHeaderField(listener.Name, key, value); + } + + /// + /// Sets the user agent used in the web view. + /// If the string is null or empty, the system default value will be used. + /// + /// The new user agent string to use. + public void SetUserAgent(string agent) { + UniWebViewInterface.SetUserAgent(listener.Name, agent); + } + + /// + /// Gets the user agent string currently used in web view. + /// If a customized user agent is not set, the default user agent in current platform will be returned. + /// + /// The user agent string in use. + public string GetUserAgent() { + return UniWebViewInterface.GetUserAgent(listener.Name); + } + + /// + /// Sets the adjustment behavior which indicates how safe area insets + /// are added to the adjusted content inset. It is a wrapper of `contentInsetAdjustmentBehavior` on iOS. + /// + /// It only works on iOS 11 and above. You need to call this method as soon as you create a web view, + /// before you call any other methods related to web view layout (like `Show` or `SetShowToolbar`). + /// + /// The behavior for determining the adjusted content offsets. + public void SetContentInsetAdjustmentBehavior( + UniWebViewContentInsetAdjustmentBehavior behavior + ) + { + #if (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_IOS) && !UNITY_EDITOR_WIN && !UNITY_EDITOR_LINUX + UniWebViewInterface.SetContentInsetAdjustmentBehavior(listener.Name, behavior); + #endif + } + + /// + /// Sets allow auto play for current web view. By default, + /// users need to touch the play button to start playing a media resource. + /// + /// By setting this to `true`, you can start the playing automatically through + /// corresponding media tag attributes. + /// + /// A flag indicates whether autoplaying of media is allowed or not. + public static void SetAllowAutoPlay(bool flag) { + UniWebViewInterface.SetAllowAutoPlay(flag); + } + + /// + /// Sets allow inline play for current web view. By default, on iOS, the video + /// can only be played in a new full screen view. + /// By setting this to `true`, you could play a video inline the page, instead of opening + /// a new full screen window. + /// + /// This only works for iOS and macOS Editor. + /// On Android, you could play videos inline by default and calling this method does nothing. + /// + /// A flag indicates whether inline playing of media is allowed or not. + public static void SetAllowInlinePlay(bool flag) { + #if (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_IOS) && !UNITY_EDITOR_WIN && !UNITY_EDITOR_LINUX + UniWebViewInterface.SetAllowInlinePlay(flag); + #endif + } + + /// + /// Sets whether loading a local file is allowed. + /// + /// If set to `false`, any load from a file URL `file://` for `Load` method will be rejected and trigger an + /// `OnPageErrorReceived` event. That means you cannot load a web page from any local file. If you are not going to + /// load any local files, setting it to `false` helps to reduce the interface of web view and improve the security. + /// + /// By default, it is `true` and the local file URL loading is allowed. + /// + /// Whether the local file access by web view loading is allowed or not. + public void SetAllowFileAccess(bool flag) { + UniWebViewInterface.SetAllowFileAccess(listener.Name, flag); + } + + /// + /// Sets whether file access from file URLs is allowed. + /// + /// By setting with `true`, access to file URLs inside the web view will be enabled and you could access + /// sub-resources or make cross origin requests from local HTML files. + /// + /// On iOS, it uses some "hidden" way by setting `allowFileAccessFromFileURLs` in config preferences for WebKit. + /// So it is possible that it stops working in a future version. + /// + /// On Android, it sets the `WebSettings.setAllowFileAccessFromFileURLs` for the current web view. + /// + /// Whether the file access inside web view from file URLs is allowed or not. + public void SetAllowFileAccessFromFileURLs(bool flag) { + UniWebViewInterface.SetAllowFileAccessFromFileURLs(listener.Name, flag); + } + + /// + /// Sets allow universal access from file URLs. By default, on iOS, the `WKWebView` forbids any load of local files + /// through AJAX even when opening a local HTML file. It checks the CORS rules and fails at web view level. + /// This is useful when you want access these files by setting the `allowUniversalAccessFromFileURLs` key of web view + /// configuration. + /// + /// On iOS and macOS Editor. It uses some "hidden" way by setting `allowUniversalAccessFromFileURLs` in config + /// for WebKit. So it is possible that it stops working in a future version. + /// + /// On Android, it sets the `WebSettings.setAllowUniversalAccessFromFileURLs` and any later-created web views uses + /// that value. + /// + /// A flag indicates whether the universal access for files are allowed or not. + public static void SetAllowUniversalAccessFromFileURLs(bool flag) { + UniWebViewInterface.SetAllowUniversalAccessFromFileURLs(flag); + } + + /// + /// Sets whether the web view area should avoid soft keyboard. It `true`, when the keyboard shows up, the web views + /// content view will resize itself to avoid keyboard overlap the web content. Otherwise, the web view will not resize + /// and just leave the content below under the soft keyboard. + /// + /// This method is only for Android. On iOS, the keyboard avoidance is built into the system directly and there is + /// no way to change its behavior. + /// + /// Whether the keyboard should avoid web view content. + public static void SetEnableKeyboardAvoidance(bool flag) { + #if UNITY_ANDROID && !UNITY_EDITOR + UniWebViewInterface.SetEnableKeyboardAvoidance(flag); + #endif + } + + /// + /// Sets whether JavaScript should be enabled in current web view. Default is enabled. + /// + /// Whether JavaScript should be enabled. + public static void SetJavaScriptEnabled(bool enabled) { + UniWebViewInterface.SetJavaScriptEnabled(enabled); + } + + /// + /// Sets whether JavaScript can open windows without user interaction. + /// + /// By setting this to `true`, an automatically JavaScript navigation will be allowed in the web view. + /// + /// Whether JavaScript could open window automatically. + public static void SetAllowJavaScriptOpenWindow(bool flag) { + UniWebViewInterface.SetAllowJavaScriptOpenWindow(flag); + } + + /// + /// Cleans web view cache. This removes cached local data of web view. + /// + /// If you need to clear all cookies, use `ClearCookies` instead. + /// + public void CleanCache() { + UniWebViewInterface.CleanCache(listener.Name); + } + + /// + /// Clears all cookies from web view. + /// + /// This will clear cookies from all domains in the web view and previous. + /// If you only need to remove cookies from a certain domain, use `SetCookie` instead. + /// + public static void ClearCookies() { + UniWebViewInterface.ClearCookies(); + } + + /// + /// Sets a cookie for a certain url. + /// + /// The url to which cookie will be set. + /// The cookie string to set. + /// + /// Whether UniWebView should skip encoding the url or not. If set to `false`, UniWebView will try to encode the url parameter before + /// using it. Otherwise, your original url string will be used to set the cookie if it is valid. Default is `false`. + /// + public static void SetCookie(string url, string cookie, bool skipEncoding = false) { + UniWebViewInterface.SetCookie(url, cookie, skipEncoding); + } + + /// + /// Gets the cookie value under a url and key. + /// + /// The url (domain) where the target cookie is. + /// The key for target cookie value. + /// + /// Whether UniWebView should skip encoding the url or not. If set to `false`, UniWebView will try to encode the url parameter before + /// using it. Otherwise, your original url string will be used to get the cookie if it is valid. Default is `false`. + /// + /// Value of the target cookie under url. + public static string GetCookie(string url, string key, bool skipEncoding = false) { + return UniWebViewInterface.GetCookie(url, key, skipEncoding); + } + + /// + /// Removes all the cookies under a url. + /// + /// The url (domain) where the cookies is under. + /// + /// Whether UniWebView should skip encoding the url or not. If set to `false`, UniWebView will try to encode the url parameter before + /// using it. Otherwise, your original url string will be used to get the cookie if it is valid. Default is `false`. + /// + public static void RemoveCookies(string url, bool skipEncoding = false) { + UniWebViewInterface.RemoveCookies(url, skipEncoding); + } + + /// + /// Removes the certain cookie under a url for the specified key. + /// + /// The url (domain) where the cookies is under. + /// The key for target cookie. + /// + /// Whether UniWebView should skip encoding the url or not. If set to `false`, UniWebView will try to encode the url parameter before + /// using it. Otherwise, your original url string will be used to get the cookie if it is valid. Default is `false`. + /// + public static void RemoveCooke(string url, string key, bool skipEncoding = false) { + UniWebViewInterface.RemoveCookie(url, key, skipEncoding); + } + + /// + /// Clears any saved credentials for HTTP authentication for both Basic and Digest. + /// + /// On both iOS and Android, the user input credentials will be stored permanently across session. + /// It could prevent your users to input username and password again until they changed. If you need the + /// credentials only living in a shorter lifetime, call this method at proper timing. + /// + /// On iOS, it will clear the credentials immediately and completely from both disk and network cache. + /// On Android, it only clears from disk database, the authentication might be still cached in the network stack + /// and will not be removed until next session (app restarting). + /// + /// The client logout mechanism should be implemented by the Web site designer (such as server sending a HTTP + /// 401 for invalidating credentials). + /// + /// + /// The host to which the credentials apply. It should not contain any thing like scheme or path part. + /// The realm to which the credentials apply. + public static void ClearHttpAuthUsernamePassword(string host, string realm) { + UniWebViewInterface.ClearHttpAuthUsernamePassword(host, realm); + } + + private Color backgroundColor = Color.white; + /// + /// Gets or sets the background color of web view. The default value is `Color.white`. + /// + public Color BackgroundColor { + get { + return backgroundColor; + } + set { + backgroundColor = value; + UniWebViewInterface.SetBackgroundColor(listener.Name, value.r, value.g, value.b, value.a); + } + } + + /// + /// Gets or sets the alpha value of the whole web view. + /// + /// You can make the game scene behind web view visible to make the web view transparent. + /// + /// Default is `1.0f`, which means totally opaque. Set it to `0.0f` will make the web view totally transparent. + /// + public float Alpha { + get { + return UniWebViewInterface.GetWebViewAlpha(listener.Name); + } + set { + UniWebViewInterface.SetWebViewAlpha(listener.Name, value); + } + } + + /// + /// Sets whether to show a loading indicator while the loading is in progress. + /// + /// Whether an indicator should show. + public void SetShowSpinnerWhileLoading(bool flag) { + UniWebViewInterface.SetShowSpinnerWhileLoading(listener.Name, flag); + } + + /// + /// Sets the text displayed in the loading indicator, if `SetShowSpinnerWhileLoading` is set to `true`. + /// + /// The text to display while loading indicator visible. Default is "Loading..." + public void SetSpinnerText(string text) { + UniWebViewInterface.SetSpinnerText(listener.Name, text); + } + + /// + /// Sets whether the horizontal scroll bar should show when the web content beyonds web view bounds. + /// + /// This only works on mobile platforms. It will do nothing on macOS Editor. + /// + /// Whether enable the scroll bar or not. + public void SetHorizontalScrollBarEnabled(bool enabled) { + UniWebViewInterface.SetHorizontalScrollBarEnabled(listener.Name, enabled); + } + + /// + /// Sets whether the vertical scroll bar should show when the web content beyonds web view bounds. + /// + /// This only works on mobile platforms. It will do nothing on macOS Editor. + /// + /// Whether enable the scroll bar or not. + public void SetVerticalScrollBarEnabled(bool enabled) { + UniWebViewInterface.SetVerticalScrollBarEnabled(listener.Name, enabled); + } + + /// + /// Sets whether the web view should show with a bounces effect when scrolling to page edge. + /// + /// This only works on mobile platforms. It will do nothing on macOS Editor. + /// + /// Whether the bounces effect should be applied or not. + public void SetBouncesEnabled(bool enabled) { + UniWebViewInterface.SetBouncesEnabled(listener.Name, enabled); + } + + /// + /// Sets whether the web view supports zoom gesture to change content size. + /// Default is `false`, which means the zoom gesture is not supported. + /// + /// Whether the zoom gesture is allowed or not. + public void SetZoomEnabled(bool enabled) { + UniWebViewInterface.SetZoomEnabled(listener.Name, enabled); + } + + /// + /// Adds a trusted domain to white list and allow permission requests from the domain. + /// + /// You only need this on Android devices with system before 6.0 when a site needs the location or camera + /// permission. It will allow the permission gets approved so you could access the corresponding devices. + /// From Android 6.0, the permission requests method is changed and this is not needed anymore. + /// + /// The domain to add to the white list. + public void AddPermissionTrustDomain(string domain) { + #if UNITY_ANDROID && !UNITY_EDITOR + UniWebViewInterface.AddPermissionTrustDomain(listener.Name, domain); + #endif + } + + /// + /// Removes a trusted domain from white list. + /// + /// The domain to remove from white list. + public void RemovePermissionTrustDomain(string domain) { + #if UNITY_ANDROID && !UNITY_EDITOR + UniWebViewInterface.RemovePermissionTrustDomain(listener.Name, domain); + #endif + } + + /// + /// Sets whether the device back button should be enabled to execute "go back" or "closing" operation. + /// + /// On Android, the device back button in navigation bar will navigate users to a back page. If there is + /// no any back page avaliable, the back button clicking will try to raise a `OnShouldClose` event and try + /// to close the web view if `true` is return from the event. If the `OnShouldClose` is not listened, + /// the web view will be closed and the UniWebView component will be destroyed to release using resource. + /// + /// Listen to `OnKeyCodeReceived` if you need to disable the back button, but still want to get the back + /// button key pressing event. + /// + /// Default is enabled. + /// + /// Whether the back button should perform go back or closing operation to web view. + public void SetBackButtonEnabled(bool enabled) { + this.backButtonEnabled = enabled; + } + + /// + /// Sets whether the web view should enable support for the "viewport" HTML meta tag or should use a wide viewport. + /// + /// Whether to enable support for the viewport meta tag. + public void SetUseWideViewPort(bool flag) { + #if UNITY_ANDROID && !UNITY_EDITOR + UniWebViewInterface.SetUseWideViewPort(listener.Name, flag); + #endif + } + + /// + /// Sets whether the web view loads pages in overview mode, that is, zooms out the content to fit on screen by width. + /// + /// This method is only for Android. Default is disabled. + /// + /// + public void SetLoadWithOverviewMode(bool flag) { + #if UNITY_ANDROID && !UNITY_EDITOR + UniWebViewInterface.SetLoadWithOverviewMode(listener.Name, flag); + #endif + } + + /// + /// Sets whether to show a toolbar which contains navigation buttons and Done button. + /// + /// You could choose to show or hide the tool bar. By configuring the `animated` and `onTop` + /// parameters, you can control the animating and position of the toolbar. If the toolbar is + /// overlapping with some part of your web view, pass `adjustInset` with `true` to have the + /// web view relocating itself to avoid the overlap. + /// + /// This method is only for iOS. The toolbar is hidden by default. + /// + /// Whether the toolbar should show or hide. + /// Whether the toolbar state changing should be with animation. Default is `false`. + /// Whether the toolbar should snap to top of screen or to bottom of screen. + /// Default is `true` + /// Whether the toolbar transition should also adjust web view position and size + /// if overlapped. Default is `false` + public void SetShowToolbar(bool show, bool animated = false, bool onTop = true, bool adjustInset = false) { + #if (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_IOS) && !UNITY_EDITOR_WIN && !UNITY_EDITOR_LINUX + UniWebViewInterface.SetShowToolbar(listener.Name, show, animated, onTop, adjustInset); + #endif + } + + /// + /// Sets the done button text in toolbar. + /// + /// By default, UniWebView will show a "Done" button at right size in the + /// toolbar. You could change its title by passing a text. + /// + /// This method is only for iOS, since there is no toolbar on Android. + /// + /// The text needed to be set as done button title. + public void SetToolbarDoneButtonText(string text) { + #if UNITY_IOS && !UNITY_EDITOR + UniWebViewInterface.SetToolbarDoneButtonText(listener.Name, text); + #endif + } + + /// + /// Sets the go back button text in toolbar. + /// + /// By default, UniWebView will show a back arrow at the left side in the + /// toolbar. You could change its text. + /// + /// This method is only for iOS and macOS Editor, since there is no toolbar on Android. + /// + /// The text needed to be set as go back button. + public void SetToolbarGoBackButtonText(string text) { + #if (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_IOS) && !UNITY_EDITOR_WIN && !UNITY_EDITOR_LINUX + UniWebViewInterface.SetToolbarGoBackButtonText(listener.Name, text); + #endif + } + + /// + /// Sets the go forward button text in toolbar. + /// + /// By default, UniWebView will show a forward arrow at the left side in the + /// toolbar. You could change its text. + /// + /// This method is only for iOS and macOS Editor, since there is no toolbar on Android. + /// + /// The text needed to be set as go forward button. + public void SetToolbarGoForwardButtonText(string text) { + #if (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_IOS) && !UNITY_EDITOR_WIN && !UNITY_EDITOR_LINUX + UniWebViewInterface.SetToolbarGoForwardButtonText(listener.Name, text); + #endif + } + + /// + /// Sets the background tint color for the toolbar. + /// + /// By default, UniWebView uses a default half-transparent iOS standard background for toolbar. + /// You can change it by setting a new opaque color. + /// + /// This method is only for iOS, since there is no toolbar on Android. + /// + /// The color should be used for the background tint of the toolbar. + public void SetToolbarTintColor(Color color) { + #if UNITY_IOS && !UNITY_EDITOR + UniWebViewInterface.SetToolbarTintColor(listener.Name, color.r, color.g, color.b); + #endif + } + + /// + /// Sets the button text color for the toolbar. + /// + /// By default, UniWebView uses the default text color on iOS, which is blue for most cases. + /// You can change it by setting a new opaque color. + /// + /// This method is only for iOS, since there is no toolbar on Android. + /// + /// The color should be used for the button text of the toolbar. + public void SetToolbarTextColor(Color color) { + #if UNITY_IOS && !UNITY_EDITOR + UniWebViewInterface.SetToolbarTextColor(listener.Name, color.r, color.g, color.b); + #endif + } + + /// + /// Sets the visibility of navigation buttons, such as "Go Back" and "Go Forward", on toolbar. + /// + /// By default, UniWebView will show the "Go Back" and "Go Forward" navigation buttons on the toolbar. + /// Users can use these buttons to perform go back or go forward action just like in a browser. If the navigation + /// model is not for your case, call this method with `false` as `show` parameter to hide them. + /// + /// This method is only for iOS, since there is no toolbar on Android. + /// + /// Whether the navigation buttons on the toolbar should show or hide. + public void SetShowToolbarNavigationButtons(bool show) { + #if (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_IOS) && !UNITY_EDITOR_WIN && !UNITY_EDITOR_LINUX + UniWebViewInterface.SetShowToolbarNavigationButtons(listener.Name, show); + #endif + } + + /// + /// Sets whether the web view can receive user interaction or not. + /// + /// By setting this to `false`, the web view will not accept any user touch event so your users cannot tap links or + /// scroll the page. + /// + /// + /// Whether the user interaction should be enabled or not. + public void SetUserInteractionEnabled(bool enabled) { + UniWebViewInterface.SetUserInteractionEnabled(listener.Name, enabled); + } + + /// + /// Sets whether the web view should pass through clicks at clear pixels to Unity scene. + /// + /// Setting this method is a pre-condition for the whole passing-through feature to work. To allow your touch passing through + /// to Unity scene, the following conditions should be met at the same time: + /// + /// 1. This method is called with `true` and the web view accepts passing-through clicks. + /// 2. The web view has a transparent background in body style for its content by CSS. + /// 3. The web view itself has a transparent background color by setting `BackgroundColor` with a clear color. + /// + /// Then, when user clicks on the clear pixel on the web view, the touch events will not be handled by the web view. + /// Instead, these events are passed to Unity scene. By using this feature, it is possible to create a native UI with the + /// web view. + /// + /// Only clicks on transparent part on the web view will be delivered to Unity scene. The web view still intercepts + /// and handles other touches on visible pixels on the web view. + /// + /// Whether the transparency clicking through feature should be enabled in this web view. + public void SetTransparencyClickingThroughEnabled(bool enabled) { + UniWebViewInterface.SetTransparencyClickingThroughEnabled(listener.Name, enabled); + } + + /// + /// Enables debugging of web contents. You could inspect of the content of a + /// web view by using a browser development tool of Chrome for Android or Safari for macOS. + /// + /// This method is only for Android and macOS Editor. On iOS, you do not need additional step. + /// You could open Safari's developer tools to debug a web view on iOS. + /// + /// Whether the content debugging should be enabled. + public static void SetWebContentsDebuggingEnabled(bool enabled) { + UniWebViewInterface.SetWebContentsDebuggingEnabled(enabled); + } + + /// + /// Enables user resizing for web view window. By default, you can only set the window size + /// by setting its frame on mac Editor. By enabling user resizing, you would be able to resize + /// the window by dragging its border as a normal macOS window. + /// + /// This method only works for macOS for debugging purpose. It does nothing on iOS and Android. + /// + /// Whether the window could be able to be resized by cursor. + public void SetWindowUserResizeEnabled(bool enabled) { + #if (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_IOS) && !UNITY_EDITOR_WIN && !UNITY_EDITOR_LINUX + UniWebViewInterface.SetWindowUserResizeEnabled(listener.Name, enabled); + #endif + } + + /// + /// Gets the HTML content from current page by accessing its outerHTML with JavaScript. + /// + /// Called after the JavaScript executed. The parameter string is the content read + /// from page. + public void GetHTMLContent(Action handler) { + EvaluateJavaScript("document.documentElement.outerHTML", payload => { + if (handler != null) { + handler(payload.data); + } + }); + } + + /// + /// Sets whether horizontal swipe gestures should trigger back-forward list navigation. + /// + /// By setting with `true`, users can swipe from screen edge to perform a back or forward navigation. + /// This method only works on iOS and macOS Editor. Default is `false`. + /// + /// On Android, the screen navigation gestures are simulating the traditional back button and it is enabled by + /// default. To disable gesture navigation on Android, you have to also disable the device back button. See + /// `SetBackButtonEnabled` for that purpose. + /// + /// + /// The value indicates whether a swipe gestures driven navigation should be allowed. Default is `false`. + /// + public void SetAllowBackForwardNavigationGestures(bool flag) { + #if (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_IOS) && !UNITY_EDITOR_WIN && !UNITY_EDITOR_LINUX + UniWebViewInterface.SetAllowBackForwardNavigationGestures(listener.Name, flag); + #endif + } + + /// + /// Sets whether a prompt alert should be displayed for collection username and password when the web view receives an + /// HTTP authentication challenge (HTTP Basic or HTTP Digest) from server. + /// + /// By setting with `false`, no prompt will be shown and the user cannot login with input credentials. In this case, + /// you can only access this page by providing username and password through the URL like: "http://username:password@example.com". + /// If the username and password does not match, normally an error with 401 as status code would be returned (this behavior depends + /// on the server implementation). If set with `true`, a prompt will be shown when there is no credentials provided or it is not + /// correct in the URL. + /// + /// Default is `true`. + /// + /// Whether a prompt alert should be shown for HTTP authentication challenge or not. + public void SetAllowHTTPAuthPopUpWindow(bool flag) { + UniWebViewInterface.SetAllowHTTPAuthPopUpWindow(listener.Name, flag); + } + + /// + /// Sets whether a callout (context) menu should be displayed when user long tapping on certain web view content. + /// + /// When enabled, when user long presses an image or link in the web page, a context menu would be show up to ask + /// user's action. On iOS, it is a action sheet to ask whether opening the target link or saving the image. On + /// Android it is a pop up dialog to ask whether saving the image to local disk. On iOS, the preview page triggered + /// by force touch on iOS is also considered as a callout menu. + /// + /// Default is `true`, means that the callout menu will be displayed. Call this method with `false` to disable + /// it on the web view. + /// + /// + /// Whether a callout menu should be displayed when user long pressing or force touching a certain web page element. + /// + public void SetCalloutEnabled(bool enabled) { + UniWebViewInterface.SetCalloutEnabled(listener.Name, enabled); + } + + /// + /// Sets whether the web view should support a pop up web view triggered by user in a new tab. + /// + /// In a general web browser (such as Google Chrome or Safari), a URL with `target="_blank"` attribute is intended + /// to be opened in a new tab. However, in the context of web view, there is no way to handle new tabs without + /// proper configurations. Due to that, by default UniWebView will ignore the `target="_blank"` and try to open + /// the page in the same web view if that kind of link is pressed. + /// + /// It works for most cases, but if this is a problem to your app logic, you can change this behavior by calling + /// this method with `true`. It enables the "opening in new tab" behavior in a limited way, by adding the new tab + /// web view above to the current web view, with the same size and position. When the opened new tab is closed, + /// it will be removed from the view hierarchy automatically. + /// + /// + /// + /// Whether to support multiple windows. If `true`, the `target="_blank"` link will be opened in a new web view. + /// Default is `false`. + /// + public void SetSupportMultipleWindows(bool enabled) { + UniWebViewInterface.SetSupportMultipleWindows(listener.Name, enabled); + } + + /// + /// Sets the default font size used in the web view. + /// + /// On Android, the web view font size can be affected by the system font scale setting. Use this method to set the + /// font size in a more reasonable way, by giving the web view another default font size with the system font scale + /// considered. It can removes or reduces the effect of system font scale when displaying the web content. + /// + /// This method only works on Android. On iOS, this method does nothing since the web view will respect the font + /// size setting in your CSS styles. + /// + /// The target default font size set to the web view. + public void SetDefaultFontSize(int size) { + #if UNITY_ANDROID && !UNITY_EDITOR + UniWebViewInterface.SetDefaultFontSize(listener.Name, size); + #endif + } + + /// + /// Sets the text zoom used in the web view. + /// + /// On Android, this method call `WebSettings.setTextZoom` to the the text zoom used in the web view. + /// + /// This method only works on Android. + /// + /// The text zoom in percent. + public void SetTextZoom(int textZoom) { + #if UNITY_ANDROID && !UNITY_EDITOR + UniWebViewInterface.SetTextZoom(listener.Name, textZoom); + #endif + } + + /// + /// Sets whether the drag interaction should be enabled on iOS. + /// + /// From iOS 11, the iPad web view supports the drag interaction when user long presses an image, link or text. + /// Setting this to `false` would disable the drag feather on the web view. + /// + /// This method only works on iOS. It does nothing on Android or macOS editor. Default is `true`, which means + /// drag interaction on iPad is enabled. + /// + /// + /// Whether the drag interaction should be enabled. + /// + public void SetDragInteractionEnabled(bool enabled) { + #if (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_IOS) && !UNITY_EDITOR_WIN && !UNITY_EDITOR_LINUX + UniWebViewInterface.SetDragInteractionEnabled(listener.Name, enabled); + #endif + } + + /// + /// Prints current page. + /// + /// By calling this method, a native print preview panel will be brought up on iOS and Android. + /// This method does nothing on macOS editor. + /// On iOS and Android, the web view does not support JavaScript (window.print()), + /// you can only initialize a print job from Unity by this method. + /// + public void Print() { + UniWebViewInterface.Print(listener.Name); + } + + /// + /// Capture the content of web view and store it to the cache path on disk with the given file name. + /// + /// When the capturing finishes, `OnCaptureSnapshotFinished` event will be raised, with an error code to indicate + /// whether the operation succeeded and an accessible disk path of the image. + /// + /// The captured image will be stored as a PNG file under the `fileName` in app's cache folder. If a file with the + /// same file name already exists, it will be overridden by the new captured image. + /// + /// + /// The file name to which the captured image is stored to, for example "screenshot.png". If empty, UniWebView will + /// pick a random UUID with "png" file extension as the file name. + /// + public void CaptureSnapshot(string fileName) { + UniWebViewInterface.CaptureSnapshot(listener.Name, fileName); + } + + /// + /// Scrolls the web view to a certain point. + /// + /// Use 0 for both `x` and `y` value to scroll the web view to its origin. + /// In a normal vertical web page, it is equivalent as scrolling to top. + /// + /// You can use the `animated` parameter to control whether scrolling the page with or without animation. + /// This parameter only works on iOS and Android. On macOS editor, the scrolling always happens without animation. + /// + /// X value of the target scrolling point. + /// Y value of the target scrolling point. + /// If `true`, the scrolling happens with animation. Otherwise, it happens without + /// animation and the content is set directly. + /// + public void ScrollTo(int x, int y, bool animated) { + UniWebViewInterface.ScrollTo(listener.Name, x, y, animated); + } + + /// + /// Adds the URL to download inspecting list. + /// + /// If a response is received in main frame and its URL is already in the inspecting list, a download task will be + /// triggered. Check "Download Files" guide for more. + /// + /// This method only works on iOS and macOS Editor. + /// + /// The inspected URL. + /// The download matching type used to match the URL. Default is `ExactValue`. + public void AddDownloadURL(string urlString, UniWebViewDownloadMatchingType type = UniWebViewDownloadMatchingType.ExactValue) { + #if (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_IOS) && !UNITY_EDITOR_WIN && !UNITY_EDITOR_LINUX + UniWebViewInterface.AddDownloadURL(listener.Name, urlString, (int)type); + #endif + } + + /// + /// Removes the URL from download inspecting list. + /// + /// If a response is received in main frame and its URL is already in the inspecting list, a download task will be + /// triggered. Check "Download Files" guide for more. + /// + /// This method only works on iOS and macOS Editor. + /// + /// The inspected URL. + /// The download matching type used to match the URL. Default is `ExactValue`. + /// + public void RemoveDownloadURL(string urlString, UniWebViewDownloadMatchingType type = UniWebViewDownloadMatchingType.ExactValue) { + #if (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_IOS) && !UNITY_EDITOR_WIN && !UNITY_EDITOR_LINUX + UniWebViewInterface.RemoveDownloadURL(listener.Name, urlString, (int)type); + #endif + } + + /// + /// Adds the MIME type to download inspecting list. + /// + /// If a response is received in main frame and its MIME type is already in the inspecting list, a + /// download task will be triggered. Check "Download Files" guide for more. + /// + /// This method only works on iOS and macOS Editor. + /// + /// The inspected MIME type of the response. + /// The download matching type used to match the MIME type. Default is `ExactValue`. + public void AddDownloadMIMEType(string MIMEType, UniWebViewDownloadMatchingType type = UniWebViewDownloadMatchingType.ExactValue) { + #if (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_IOS) && !UNITY_EDITOR_WIN && !UNITY_EDITOR_LINUX + UniWebViewInterface.AddDownloadMIMEType(listener.Name, MIMEType, (int)type); + #endif + } + + /// + /// Removes the MIME type from download inspecting list. + /// + /// If a response is received in main frame and its MIME type is already in the inspecting list, a + /// download task will be triggered. Check "Download Files" guide for more. + /// + /// This method only works on iOS and macOS Editor. + /// + /// The inspected MIME type of the response. + /// The download matching type used to match the MIME type. Default is `ExactValue`. + public void RemoveDownloadMIMETypes(string MIMEType, UniWebViewDownloadMatchingType type = UniWebViewDownloadMatchingType.ExactValue) { + #if (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_IOS) && !UNITY_EDITOR_WIN && !UNITY_EDITOR_LINUX + UniWebViewInterface.RemoveDownloadMIMETypes(listener.Name, MIMEType, (int)type); + #endif + } + + /// + /// Sets whether allowing users to choose the way to handle the downloaded file. Default is `true`. + /// + /// On iOS, the downloaded file will be stored in a temporary folder. Setting this to `true` will show a system + /// default share sheet and give the user a chance to send and store the file to another location (such as the + /// File app or iCloud). + /// + /// On macOS Editor, setting this to `true` will allow UniWebView to open the file in Finder. + /// + /// This method does not have any effect on Android. On Android, the file is downloaded to the Download folder. + /// + /// + /// + public void SetAllowUserChooseActionAfterDownloading(bool allowed) { + #if (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_IOS) && !UNITY_EDITOR_WIN && !UNITY_EDITOR_LINUX + UniWebViewInterface.SetAllowUserChooseActionAfterDownloading(listener.Name, allowed); + #endif + } + + /// + /// Sets whether the `OnFileDownloadStarted` and `OnFileDownloadFinished` events should be raised even for an image + /// saving action triggered by the callout (context) menu on Android. + /// + /// By default, the image saving goes through a different route and it does not trigger the `OnFileDownloadStarted` + /// and `OnFileDownloadFinished` events like other normal download tasks. Setting this with enabled with `true` if + /// you also need to get notified when user long-presses on the image and taps "Save Image" button. By default, the + /// image will be saved to the Downloads directory and you can get the path from the parameter + /// of `OnFileDownloadFinished` event. + /// + /// This only works on Android. On iOS, there is no way to get a callback or any event from the "Add to Photos" + /// button in the callout menu. + /// + /// Whether the context menu image saving action triggers the download related events. + public void SetDownloadEventForContextMenuEnabled(bool enabled) { + #if UNITY_ANDROID && !UNITY_EDITOR + UniWebViewInterface.SetDownloadEventForContextMenuEnabled(listener.Name, enabled); + #endif + } + + void OnDestroy() { + UniWebViewNativeListener.RemoveListener(listener.Name); + UniWebViewInterface.Destroy(listener.Name); + Destroy(listener.gameObject); + } + + /* ////////////////////////////////////////////////////// + // Internal Listener Interface + ////////////////////////////////////////////////////// */ + internal void InternalOnShowTransitionFinished(string identifier) { + Action action; + if (actions.TryGetValue(identifier, out action)) { + action(); + actions.Remove(identifier); + } + } + + internal void InternalOnHideTransitionFinished(string identifier) { + Action action; + if (actions.TryGetValue(identifier, out action)) { + action(); + actions.Remove(identifier); + } + } + + internal void InternalOnAnimateToFinished(string identifier) { + Action action; + if (actions.TryGetValue(identifier, out action)) { + action(); + actions.Remove(identifier); + } + } + + internal void InternalOnAddJavaScriptFinished(UniWebViewNativeResultPayload payload) { + Action action; + var identifier = payload.identifier; + if (payloadActions.TryGetValue(identifier, out action)) { + action(payload); + payloadActions.Remove(identifier); + } + } + + internal void InternalOnEvalJavaScriptFinished(UniWebViewNativeResultPayload payload) { + Action action; + var identifier = payload.identifier; + if (payloadActions.TryGetValue(identifier, out action)) { + action(payload); + payloadActions.Remove(identifier); + } + } + + internal void InternalOnPageFinished(UniWebViewNativeResultPayload payload) { + if (OnPageFinished != null) { + int code = -1; + if (int.TryParse(payload.resultCode, out code)) { + OnPageFinished(this, code, payload.data); + } else { + UniWebViewLogger.Instance.Critical("Invalid status code received: " + payload.resultCode); + } + } + } + + internal void InternalOnPageStarted(string url) { + if (OnPageStarted != null) { + OnPageStarted(this, url); + } + } + + internal void InternalOnPageErrorReceived(UniWebViewNativeResultPayload payload) { + if (OnPageErrorReceived != null) { + int code = -1; + if (int.TryParse(payload.resultCode, out code)) { + OnPageErrorReceived(this, code, payload.data); + } else { + UniWebViewLogger.Instance.Critical("Invalid error code received: " + payload.resultCode); + } + } + } + + internal void InternalOnPageProgressChanged(float progress) { + if (OnPageProgressChanged != null) { + OnPageProgressChanged(this, progress); + } + } + + internal void InternalOnMessageReceived(string result) { + if (OnMessageReceived != null) { + var message = new UniWebViewMessage(result); + OnMessageReceived(this, message); + } + } + + internal void InternalOnShouldClose() { + if (OnShouldClose != null) { + var shouldClose = OnShouldClose(this); + if (shouldClose) { + Destroy(this); + } + } else { + Destroy(this); + } + } + + internal void InternalOnWebContentProcessDidTerminate() { + if (OnWebContentProcessTerminated != null) { + OnWebContentProcessTerminated(this); + } + } + + internal void InternalOnMultipleWindowOpened(string multiWindowId) { + if (OnMultipleWindowOpened != null) { + OnMultipleWindowOpened(this, multiWindowId); + } + } + + internal void InternalOnMultipleWindowClosed(string multiWindowId) { + if (OnMultipleWindowClosed != null) { + OnMultipleWindowClosed(this, multiWindowId); + } + } + + internal void InternalOnFileDownloadStarted(UniWebViewNativeResultPayload payload) { + if (OnFileDownloadStarted != null) { + OnFileDownloadStarted(this, payload.identifier, payload.data); + } + } + + internal void InternalOnFileDownloadFinished(UniWebViewNativeResultPayload payload) { + if (OnFileDownloadFinished != null) { + int errorCode = int.TryParse(payload.resultCode, out errorCode) ? errorCode : -1; + OnFileDownloadFinished(this, errorCode, payload.identifier, payload.data); + } + } + + internal void InternalOnCaptureSnapshotFinished(UniWebViewNativeResultPayload payload) { + if (OnCaptureSnapshotFinished != null) { + int errorCode = int.TryParse(payload.resultCode, out errorCode) ? errorCode : -1; + OnCaptureSnapshotFinished(this, errorCode, payload.data); + } + } + + [Obsolete("SetImmersiveModeEnabled is deprecated. Now UniWebView always respect navigation bar/status bar settings from Unity.", false)] + /// + /// Sets whether the web view should behave in immersive mode, that is, + /// hides the status bar and navigation bar with a sticky style. + /// + /// This method is only for Android. Default is enabled. + /// + /// + public void SetImmersiveModeEnabled(bool enabled) { + Debug.LogError( + "SetImmersiveModeEnabled is removed in UniWebView 4." + + "Now UniWebView always respect navigation bar/status bar settings from Unity." + ); + } + + [Obsolete("KeyCodeReceivedDelegate is deprecated. Now UniWebView never intercepts device key code events. Check `Input.GetKeyUp` instead.", false)] + /// + /// Delegate for code keycode received event. + /// + /// The web view component which raises this event. + /// The key code of pressed key. See [Android API for keycode](https://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_0) to know the possible values. + public delegate void KeyCodeReceivedDelegate(UniWebView webView, int keyCode); + + [Obsolete("OnKeyCodeReceived is deprecated and never called. Now UniWebView never intercepts device key code events. Check `Input.GetKeyUp` instead.", false)] + /// + /// Raised when a key (like back button or volume up) on the device is pressed. + /// + /// This event only raised on Android. It is useful when you disabled the back button but still need to + /// get the back button event. On iOS, user's key action is not avaliable and this event will never be + /// raised. + /// + #pragma warning disable CS0067 + public event KeyCodeReceivedDelegate OnKeyCodeReceived; + +} \ No newline at end of file diff --git a/Assets/UniWebView/Script/UniWebView.cs.meta b/Assets/UniWebView/Script/UniWebView.cs.meta new file mode 100644 index 00000000..891198ab --- /dev/null +++ b/Assets/UniWebView/Script/UniWebView.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 598e18fb001004a81960f552978ecf4e +timeCreated: 1491898971 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Script/UniWebViewContentInsetAdjustmentBehavior.cs b/Assets/UniWebView/Script/UniWebViewContentInsetAdjustmentBehavior.cs new file mode 100644 index 00000000..e2b467c0 --- /dev/null +++ b/Assets/UniWebView/Script/UniWebViewContentInsetAdjustmentBehavior.cs @@ -0,0 +1,42 @@ +// +// UniWebViewContentInsetAdjustmentBehavior.cs +// Created by Wang Wei(@onevcat) on 2019-09-20. +// +// 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. + +/// +/// Constants indicating how safe area insets are added to the adjusted content inset. +/// This is only for iOS. +/// +public enum UniWebViewContentInsetAdjustmentBehavior +{ + /// + /// Automatically adjust the scroll view insets. + /// + Automatic = 0, + + /// + /// Adjust the insets only in the scrollable directions. + /// + ScrollableAxes = 1, + + /// + /// Do not adjust the scroll view insets. + /// + Never = 2, + + /// + /// Always include the safe area insets in the content adjustment. + /// + Always = 3 +} \ No newline at end of file diff --git a/Assets/UniWebView/Script/UniWebViewContentInsetAdjustmentBehavior.cs.meta b/Assets/UniWebView/Script/UniWebViewContentInsetAdjustmentBehavior.cs.meta new file mode 100644 index 00000000..c05136b2 --- /dev/null +++ b/Assets/UniWebView/Script/UniWebViewContentInsetAdjustmentBehavior.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dc6b999829de442f2aa381a8ff78a917 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Script/UniWebViewDownloadMatchingType.cs b/Assets/UniWebView/Script/UniWebViewDownloadMatchingType.cs new file mode 100644 index 00000000..8e7abad0 --- /dev/null +++ b/Assets/UniWebView/Script/UniWebViewDownloadMatchingType.cs @@ -0,0 +1,32 @@ +// +// UniWebViewDownloadMatchingType.cs +// Created by Wang Wei(@onevcat) on 2021-09-02. +// +// 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. +// + +/// +/// The matching type used when UniWebView determines whether to download from a URL or MIME type. +/// +public enum UniWebViewDownloadMatchingType +{ + /// + /// Matches exact the whole value. + /// + ExactValue = 1, + /// + /// Uses the value as a regular expression. + /// + RegularExpression = 2 +} + diff --git a/Assets/UniWebView/Script/UniWebViewDownloadMatchingType.cs.meta b/Assets/UniWebView/Script/UniWebViewDownloadMatchingType.cs.meta new file mode 100644 index 00000000..f5e52c71 --- /dev/null +++ b/Assets/UniWebView/Script/UniWebViewDownloadMatchingType.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0ba73f1cc351846878c5731b4e22b132 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Script/UniWebViewHelper.cs b/Assets/UniWebView/Script/UniWebViewHelper.cs new file mode 100644 index 00000000..0cbf3eb5 --- /dev/null +++ b/Assets/UniWebView/Script/UniWebViewHelper.cs @@ -0,0 +1,67 @@ +// +// UniWebViewHelper.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. +// +using UnityEngine; +using System.IO; + +/// +/// Provides some helper utility methods for UniWebView. +/// +public class UniWebViewHelper { + /// + /// Get the local streaming asset path for a given file path related to the StreamingAssets folder. + /// + /// This method will help you to create a URL string for a file under your StreamingAssets folder for different platforms. + /// 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/index.html` as parameter. + /// + /// The path you could use as the url for the web view. + public static string StreamingAssetURLForPath(string path) + { +#if (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_IOS) && !UNITY_EDITOR_WIN && !UNITY_EDITOR_LINUX + return Path.Combine("file://" + Application.streamingAssetsPath, path); +#elif UNITY_ANDROID && !UNITY_EDITOR_WIN && !UNITY_EDITOR_LINUX + return Path.Combine("file:///android_asset/", path); +#else + UniWebViewLogger.Instance.Critical("The current build target is not supported."); + return string.Empty; +#endif + } + + /// + /// Get the local persistent data path for a given file path related to the data folder of your host app. + /// + /// This method will help you to create a URL string for a file under you stored in the `persistentDataPath`. + /// + /// + /// The relative path to the persistent data path of your file. + /// + /// The path you could use as the url for the web view. + public static string PersistentDataURLForPath(string path) + { + return Path.Combine("file://" + Application.persistentDataPath, path); + } + + internal static bool IsEditor { + get { + #if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX + return true; + #else + return false; + #endif + } + } +} diff --git a/Assets/UniWebView/Script/UniWebViewHelper.cs.meta b/Assets/UniWebView/Script/UniWebViewHelper.cs.meta new file mode 100644 index 00000000..4eeae451 --- /dev/null +++ b/Assets/UniWebView/Script/UniWebViewHelper.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 824ddd9d1592945268d857265662a174 +timeCreated: 1495373327 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Script/UniWebViewLogger.cs b/Assets/UniWebView/Script/UniWebViewLogger.cs new file mode 100644 index 00000000..e2be3e1a --- /dev/null +++ b/Assets/UniWebView/Script/UniWebViewLogger.cs @@ -0,0 +1,120 @@ +// +// UniWebViewLogger.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. +// + +/// +/// A leveled logger which could log UniWebView related messages in +/// both development environment and final product. +/// +public class UniWebViewLogger { + /// + /// Logger level. + /// + public enum Level { + /// + /// Lowest level. When set to `Verbose`, the logger will log out all messages. + /// + Verbose = 0, + + /// + /// Debug level. When set to `Debug`, the logger will log out most of messages up to this level. + /// + Debug = 10, + + /// + /// Info level. When set to `Info`, the logger will log out up to info messages. + /// + Info = 20, + + /// + /// Critical level. When set to `Critical`, the logger will only log out errors or exceptions. + /// + Critical = 80, + + /// + /// Off level. When set to `Off`, the logger will log out nothing. + /// + Off = 99 + } + + private static UniWebViewLogger instance; + private Level level; + + /// + /// Current level of this logger. All messages above current level will be logged out. + /// Default is `Critical`, which means the logger only prints errors and exceptions. + /// + public Level LogLevel { + get { return level; } + set { + Log(Level.Off, "Setting UniWebView logger level to: " + value); + level = value; + UniWebViewInterface.SetLogLevel((int)value); + } + } + + private UniWebViewLogger(Level level) { + this.level = level; + } + + /// + /// Instance of the UniWebView logger across the process. Normally you should use this for logging purpose + /// in UniWebView, instead of creating a new logger yourself. + /// + public static UniWebViewLogger Instance { + get { + if (instance == null) { + instance = new UniWebViewLogger(Level.Critical); + } + return instance; + } + } + + /// + /// Log a verbose message. + /// + /// The message to log. + public void Verbose(string message) { Log(Level.Verbose, message); } + + /// + /// Log a debug message. + /// + /// The message to log. + public void Debug(string message) { Log(Level.Debug, message); } + + /// + /// Log an info message. + /// + /// The message to log. + public void Info(string message) { Log(Level.Info, message); } + + /// + /// Log a critical message. + /// + /// The message to log. + public void Critical(string message) { Log(Level.Critical, message); } + + private void Log(Level level, string message) { + if (level >= this.LogLevel) { + var logMessage = " " + message; + if (level == Level.Critical) { + UnityEngine.Debug.LogError(logMessage); + } else { + UnityEngine.Debug.Log(logMessage); + } + } + } +} \ No newline at end of file diff --git a/Assets/UniWebView/Script/UniWebViewLogger.cs.meta b/Assets/UniWebView/Script/UniWebViewLogger.cs.meta new file mode 100644 index 00000000..b12e2f1b --- /dev/null +++ b/Assets/UniWebView/Script/UniWebViewLogger.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 06ca7a8564d9842ba99c77d43e9ce4f5 +timeCreated: 1491898971 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Script/UniWebViewMessage.cs b/Assets/UniWebView/Script/UniWebViewMessage.cs new file mode 100644 index 00000000..b8a26a25 --- /dev/null +++ b/Assets/UniWebView/Script/UniWebViewMessage.cs @@ -0,0 +1,111 @@ +// +// UniWebViewMessage.cs +// Created by Wang Wei(@onevcat) on 2017-05-12. +// +// 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. +// +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Networking; + +#if UNITY_2017_3_OR_NEWER +using Net = UnityEngine.Networking.UnityWebRequest; +#else +using Net = UnityEngine.WWW; +#endif + +/// +/// A structure represents a message from webview. +/// +public struct UniWebViewMessage { + /// + /// Gets the raw message. It is the original url which initialized this message. + /// + public string RawMessage {get; private set;} + + /// + /// The url scheme of this UniWebViewMessage. "uniwebview" was added to message scheme list + /// by default. You can add your own scheme by using `UniWebView.AddUrlScheme`. + /// + public string Scheme {get; private set;} + + /// + /// The path of this UniWebViewMessage. + /// This will be the decoded value for the path of original url. + /// + public string Path {get; private set;} + + /// + /// The arguments of this UniWebViewMessage. + /// + /// When received url "uniwebview://yourPath?param1=value1¶m2=value2", + /// the args is a Dictionary with: Args["param1"] = value1, Args["param2"] = value2 + /// + /// Both the key and valud will be url decoded from the original url. + /// + public Dictionary Args{get; private set;} + + /// + /// Initializes a new instance of the `UniWebViewMessage` struct. + /// + /// Raw message which will be parsed to a UniWebViewMessage. + public UniWebViewMessage(string rawMessage): this() { + UniWebViewLogger.Instance.Debug("Try to parse raw message: " + rawMessage); + this.RawMessage = rawMessage; + + string[] schemeSplit = rawMessage.Split(new string[] {"://"}, System.StringSplitOptions.None); + if (schemeSplit.Length == 1) { + // `://` not existing. Try `:/` instead. + schemeSplit = rawMessage.Split(new string[] {":/"}, System.StringSplitOptions.None); + } + if (schemeSplit.Length == 1) { + // `:/` not existing. Try `:` instead. + schemeSplit = rawMessage.Split(new string[] {":"}, System.StringSplitOptions.None); + } + + if (schemeSplit.Length >= 2) { + this.Scheme = schemeSplit[0]; + UniWebViewLogger.Instance.Debug("Get scheme: " + this.Scheme); + + string pathAndArgsString = ""; + int index = 1; + while (index < schemeSplit.Length) { + pathAndArgsString = string.Concat(pathAndArgsString, schemeSplit[index]); + index++; + } + UniWebViewLogger.Instance.Verbose("Build path and args string: " + pathAndArgsString); + + string[] split = pathAndArgsString.Split("?"[0]); + + this.Path = Net.UnEscapeURL(split[0].TrimEnd('/')); + this.Args = new Dictionary(); + if (split.Length > 1) { + foreach (string pair in split[1].Split("&"[0])) { + string[] elems = pair.Split("="[0]); + if (elems.Length > 1) { + var key = Net.UnEscapeURL(elems[0]); + if (Args.ContainsKey(key)) { + var existingValue = Args[key]; + Args[key] = existingValue + "," + Net.UnEscapeURL(elems[1]); + } else { + Args[key] = Net.UnEscapeURL(elems[1]); + } + UniWebViewLogger.Instance.Debug("Get arg, key: " + key + " value: " + Args[key]); + } + } + } + } else { + UniWebViewLogger.Instance.Critical("Bad url scheme. Can not be parsed to UniWebViewMessage: " + rawMessage); + } + } +} \ No newline at end of file diff --git a/Assets/UniWebView/Script/UniWebViewMessage.cs.meta b/Assets/UniWebView/Script/UniWebViewMessage.cs.meta new file mode 100644 index 00000000..7432d6c4 --- /dev/null +++ b/Assets/UniWebView/Script/UniWebViewMessage.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0dbdb1ed01b9747a1ad6eb7bcc7b4014 +timeCreated: 1491898971 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Script/UniWebViewNativeListener.cs b/Assets/UniWebView/Script/UniWebViewNativeListener.cs new file mode 100644 index 00000000..2f225456 --- /dev/null +++ b/Assets/UniWebView/Script/UniWebViewNativeListener.cs @@ -0,0 +1,196 @@ +// +// UniWebViewNativeListener.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. +// +using UnityEngine; +using System.Collections; +using System.Collections.Generic; +using System; + +/// +/// A listener script for message sent from native side of UniWebView. +/// Normally this component will be attached to a sub `GameObject` under the `UniWebView` one. +/// It will be added automatically and destroyed as needed. So there is rarely a need for you +/// to manipulate on this class. +/// +public class UniWebViewNativeListener: MonoBehaviour { + + private static Dictionary listeners = new Dictionary(); + public static void AddListener(UniWebViewNativeListener target) { + listeners.Add(target.Name, target); + } + + public static void RemoveListener(String name) { + listeners.Remove(name); + } + + public static UniWebViewNativeListener GetListener(String name) { + UniWebViewNativeListener result = null; + if (listeners.TryGetValue(name, out result)) { + return result; + } else { + return null; + } + } + + /// + /// The web view holder of this listener. + /// It will be linked to original web view in web view context, so you should never set it yourself. + /// Either `webView` or `safeBrowsing` will be valid in this listener. + /// + [HideInInspector] + public UniWebView webView; + + // The safe browsing of this listener. + /// It will be linked to original safe browsing in browsing context, so you should never set it yourself. + /// Either `webView` or `safeBrowsing` will be valid in this listener. + [HideInInspector] + public UniWebViewSafeBrowsing safeBrowsing; + + /// + /// Name of current listener. This is a UUID string by which native side could use to find + /// the message destination. + /// + public string Name { + get { + return gameObject.name; + } + } + + public void PageStarted(string url) { + UniWebViewLogger.Instance.Info("Page Started Event. Url: " + url); + webView.InternalOnPageStarted(url); + } + + public void PageFinished(string result) { + UniWebViewLogger.Instance.Info("Page Finished Event. Url: " + result); + var payload = JsonUtility.FromJson(result); + webView.InternalOnPageFinished(payload); + } + + public void PageErrorReceived(string result) { + UniWebViewLogger.Instance.Info("Page Error Received Event. Result: " + result); + var payload = JsonUtility.FromJson(result); + webView.InternalOnPageErrorReceived(payload); + } + + public void PageProgressChanged(string result) { + float progress; + if (float.TryParse(result, out progress)) { + webView.InternalOnPageProgressChanged(progress); + } + } + + public void ShowTransitionFinished(string identifer) { + UniWebViewLogger.Instance.Info("Show Transition Finished Event. Identifier: " + identifer); + webView.InternalOnShowTransitionFinished(identifer); + } + + public void HideTransitionFinished(string identifer) { + UniWebViewLogger.Instance.Info("Hide Transition Finished Event. Identifier: " + identifer); + webView.InternalOnHideTransitionFinished(identifer); + } + + public void AnimateToFinished(string identifer) { + UniWebViewLogger.Instance.Info("Animate To Finished Event. Identifier: " + identifer); + webView.InternalOnAnimateToFinished(identifer); + } + + public void AddJavaScriptFinished(string result) { + UniWebViewLogger.Instance.Info("Add JavaScript Finished Event. Result: " + result); + var payload = JsonUtility.FromJson(result); + webView.InternalOnAddJavaScriptFinished(payload); + } + + public void EvalJavaScriptFinished(string result) { + UniWebViewLogger.Instance.Info("Eval JavaScript Finished Event. Result: " + result); + + var payload = JsonUtility.FromJson(result); + webView.InternalOnEvalJavaScriptFinished(payload); + } + + public void MessageReceived(string result) { + UniWebViewLogger.Instance.Info("Message Received Event. Result: " + result); + webView.InternalOnMessageReceived(result); + } + + public void WebViewDone(string param) { + UniWebViewLogger.Instance.Info("Web View Done Event."); + webView.InternalOnShouldClose(); + } + + public void WebContentProcessDidTerminate(string param) { + UniWebViewLogger.Instance.Info("Web Content Process Terminate Event."); + webView.InternalOnWebContentProcessDidTerminate(); + } + + public void SafeBrowsingFinished(string param) { + UniWebViewLogger.Instance.Info("Safe Browsing Finished."); + safeBrowsing.InternalSafeBrowsingFinished(); + } + + public void MultipleWindowOpened(string param) { + UniWebViewLogger.Instance.Info("MultipleWindowOpened Event. Multi Window: " + param); + webView.InternalOnMultipleWindowOpened(param); + } + + public void MultipleWindowClosed(string param) { + UniWebViewLogger.Instance.Info("MultipleWindowClose Event. Multi Window: " + param); + webView.InternalOnMultipleWindowClosed(param); + } + + public void FileDownloadStarted(string result) { + UniWebViewLogger.Instance.Info("FileDownloadStarted Event. Result: " + result); + + var payload = JsonUtility.FromJson(result); + webView.InternalOnFileDownloadStarted(payload); + } + + public void FileDownloadFinished(string result) { + UniWebViewLogger.Instance.Info("FileDownloadFinished Event. Result: " + result); + + var payload = JsonUtility.FromJson(result); + webView.InternalOnFileDownloadFinished(payload); + } + + public void CaptureSnapshotFinished(string result) { + UniWebViewLogger.Instance.Info("CaptureSnapshotFinished Event. Result: " + result); + + var payload = JsonUtility.FromJson(result); + webView.InternalOnCaptureSnapshotFinished(payload); + } +} + +/// +/// A payload received from native side. It contains information to identify the message sender, +/// as well as some necessary field to bring data from native side to Unity. +/// +[System.Serializable] +public class UniWebViewNativeResultPayload { + /// + /// The identifier bound to this payload. It would be used internally to identify the callback. + /// + public string identifier; + /// + /// The result code contained in this payload. Generally, "0" means the operation finished without + /// problem, while a non-zero value means somethings goes wrong. + /// + public string resultCode; + /// + /// Return value or data from native. You should look at + /// corresponding APIs to know what exactly contained in this. + /// + public string data; +} \ No newline at end of file diff --git a/Assets/UniWebView/Script/UniWebViewNativeListener.cs.meta b/Assets/UniWebView/Script/UniWebViewNativeListener.cs.meta new file mode 100644 index 00000000..077e468c --- /dev/null +++ b/Assets/UniWebView/Script/UniWebViewNativeListener.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5538b25d1713f4de994dacdc6eaacb95 +timeCreated: 1491961733 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Script/UniWebViewSafeBrowingComponent.cs b/Assets/UniWebView/Script/UniWebViewSafeBrowingComponent.cs new file mode 100644 index 00000000..4f7b985f --- /dev/null +++ b/Assets/UniWebView/Script/UniWebViewSafeBrowingComponent.cs @@ -0,0 +1,20 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class UniWebViewSafeBrowingComponent : MonoBehaviour +{ + [SerializeField] + #pragma warning disable 0649 + private string url; + + void Start() + { + if (string.IsNullOrEmpty(url)) { + Debug.LogError("The `url` is empty or null. Set a valid url in the prefab before you initialize it."); + return; + } + var safeBrowsing = UniWebViewSafeBrowsing.Create(url); + safeBrowsing.Show(); + } +} diff --git a/Assets/UniWebView/Script/UniWebViewSafeBrowingComponent.cs.meta b/Assets/UniWebView/Script/UniWebViewSafeBrowingComponent.cs.meta new file mode 100644 index 00000000..bdd0b295 --- /dev/null +++ b/Assets/UniWebView/Script/UniWebViewSafeBrowingComponent.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5843488507315421aa0a7d92c0604d10 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Script/UniWebViewSafeBrowsing.cs b/Assets/UniWebView/Script/UniWebViewSafeBrowsing.cs new file mode 100644 index 00000000..5cd27a35 --- /dev/null +++ b/Assets/UniWebView/Script/UniWebViewSafeBrowsing.cs @@ -0,0 +1,194 @@ +// +// UniWebViewSafeBrowsing.cs +// Created by Wang Wei(@onevcat) on 2020-07-18. +// +// 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. +// + +using UnityEngine; +using System; + +/// +/// UniWebView Safe Browsing provides a way for browsing the web content in a more browser-like way, such as Safari on +/// iOS and Chrome on Android. +/// +/// This class wraps `SFSafariViewController` on iOS and "Custom Tabs" on Android. It shares cookies, auto-fill +/// completion and other more data with the browser on device. Most of permissions are also built-in supported. You can +/// use this class for some tasks that are limited for a normal web view, such as using Apple Pay or Progressive Web +/// Apps (PWA). +/// +/// You create a `UniWebViewSafeBrowsing` instance by calling the static `UniWebViewSafeBrowsing.Create` method with a +/// destination URL. You cannot change this URL once the instance is created. To show the safe browsing, call `Show` on +/// the instance. The web content will be displayed in full screen with a toolbar containing the loaded URL, as well +/// as some basic controls like Go Back, Go Forward and Done. +/// +/// Browsing web content in `UniWebViewSafeBrowsing` is only supported on iOS and Android. There is no such component in +/// Unity Editor. Creating and showing a `UniWebViewSafeBrowsing` on Unity Editor will fall back to open the URL in +/// external browser by using Unity's `Application.OpenURL`. +/// +/// +public class UniWebViewSafeBrowsing: UnityEngine.Object { + + /// + /// Delegate for safe browsing finish event. + /// + /// The `UniWebViewSafeBrowsing` object raised this event. + public delegate void OnSafeBrowsingFinishedDelegate(UniWebViewSafeBrowsing browsing); + /// + /// Raised when user dismisses safe browsing by tapping the Done button or Back button. + /// + /// The dismissed safe browsing instance will be invalid after this event being raised, and you should not use + /// it for another browsing purpose. Instead, create a new one for a new browsing session. + /// + /// This event will not happen in Unity Editor, because the whole `UniWebViewSafeBrowsing` will fall back to an + /// external browser. + /// + public event OnSafeBrowsingFinishedDelegate OnSafeBrowsingFinished; + + private string id = Guid.NewGuid().ToString(); + private UniWebViewNativeListener listener; + + // This is only for editor, to open the url in system browser. + private string url; + + /// + /// Whether the safe browsing mode is supported in current runtime or not. + /// + /// If supported, the safe browsing mode will be used when `Show` is called on a `UniWebViewSafeBrowsing` instance. + /// Otherwise, the system default browser will be used to open the page when `Show` is called. + /// + /// This property always returns `true` on iOS runtime platform. On Android, it depends on whether there is an Intent + /// can handle the safe browsing request. Usually it is provided by Chrome. If there is no Intent can open the URL + /// in safe browsing mode, this property will return `false`. + /// + /// To use this API on Android when you set your Target SDK to Android 11 or later, you need to declare the correct + /// intent query explicitly in your AndroidManifest.xml, to follow the Package Visibility + /// (https://developer.android.com/about/versions/11/privacy/package-visibility): + /// + /// ```xml + /// + /// + /// + /// + /// + /// ``` + /// + /// + /// Returns `true` if the safe browsing mode is supported and the page will be opened in safe browsing + /// mode. Otherwise, `false`. + /// + public static bool IsSafeBrowsingSupported { + get { + #if UNITY_EDITOR + return false; + #elif UNITY_IOS + return true; + #elif UNITY_ANDROID + return UniWebViewInterface.IsSafeBrowsingSupported(); + #else + return false; + #endif + } + } + + /// + /// Creates a new `UniWebViewSafeBrowsing` instance with a given URL. + /// + /// The URL to navigate to. The URL must use the `http` or `https` scheme. + /// A newly created `UniWebViewSafeBrowsing` instance. + public static UniWebViewSafeBrowsing Create(string url) { + var safeBrowsing = new UniWebViewSafeBrowsing(); + if (!UniWebViewHelper.IsEditor) { + safeBrowsing.listener.safeBrowsing = safeBrowsing; + safeBrowsing.Init(url); + } + safeBrowsing.url = url; + + return safeBrowsing; + } + + /// + /// Shows the safe browsing content above current screen. + /// + public void Show() { + if (UniWebViewSafeBrowsing.IsSafeBrowsingSupported) { + UniWebViewInterface.SafeBrowsingShow(listener.Name); + } else { + if (!UniWebViewHelper.IsEditor) { + UniWebViewLogger.Instance.Critical(@"UniWebViewSafeBrowsing.Show is called but the current device does + not support Safe Browsing. + This might be due to Chrome or any other processing app is not installed, or the manifest file not + configured correctly. Check SafeBrowsing Mode guide for more: https://docs.uniwebview.com/guide/safe-browsing.html"); + } + Application.OpenURL(url); + } + } + + /// + /// Dismisses the safe browsing component. + /// + /// This method only works on iOS. On Android, there is no way to dismiss the safe browsing component + /// programatically as the result of the limitation from the native (Android) side. + /// + public void Dismiss() { + #if UNITY_IOS && !UNITY_EDITOR + UniWebViewInterface.SafeBrowsingDismiss(listener.Name); + #endif + } + + /// + /// Sets the color for toolbar background in the safe browsing component. The changes are ignored after `Show` + /// method is called. + /// + /// The color to tint the toolbar. + public void SetToolbarColor(Color color) { + if (!UniWebViewHelper.IsEditor) { + UniWebViewInterface.SafeBrowsingSetToolbarColor(listener.Name, color.r, color.g, color.b); + } + } + + /// + /// Sets the color for toolbar controls in the safe browsing component. The changes are ignored after `Show` method + /// is called. + /// + /// This method only works on iOS. On Android, the controls color is determined by system to keep a reasonable + /// contrast, based on the toolbar background color you provided in `SetToolbarColor`. + /// + /// The color to tint the controls on toolbar. + public void SetToolbarItemColor(Color color) { + #if UNITY_IOS && !UNITY_EDITOR + UniWebViewInterface.SafeBrowsingSetToolbarItemColor(listener.Name, color.r, color.g, color.b); + #endif + } + + private UniWebViewSafeBrowsing() { + if (!UniWebViewHelper.IsEditor) { + var listenerObject = new GameObject(id); + listener = listenerObject.AddComponent(); + UniWebViewNativeListener.AddListener(listener); + } + } + + private void Init(string url) { + UniWebViewInterface.SafeBrowsingInit(listener.Name, url); + } + + internal void InternalSafeBrowsingFinished() { + if (OnSafeBrowsingFinished != null) { + OnSafeBrowsingFinished(this); + } + + UniWebViewNativeListener.RemoveListener(listener.Name); + Destroy(listener.gameObject); + } +} \ No newline at end of file diff --git a/Assets/UniWebView/Script/UniWebViewSafeBrowsing.cs.meta b/Assets/UniWebView/Script/UniWebViewSafeBrowsing.cs.meta new file mode 100644 index 00000000..3d7276c8 --- /dev/null +++ b/Assets/UniWebView/Script/UniWebViewSafeBrowsing.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dca3ba926a98540d3a2bff6312899a75 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Script/UniWebViewToolbarPosition.cs b/Assets/UniWebView/Script/UniWebViewToolbarPosition.cs new file mode 100644 index 00000000..6d48c14f --- /dev/null +++ b/Assets/UniWebView/Script/UniWebViewToolbarPosition.cs @@ -0,0 +1,32 @@ +// +// UniWebViewToolbarPosition.cs +// Created by Wang Wei(@onevcat) on 2017-05-31. +// +// 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. +// + +/// +/// Toolbar position of webview. You can set the snapping edge for the built-in toolbar in iOS. +/// +public enum UniWebViewToolbarPosition +{ + /// + /// Top screen edge. + /// + Top = 0, + /// + /// Bottom screen edge. + /// + Bottom +} + diff --git a/Assets/UniWebView/Script/UniWebViewToolbarPosition.cs.meta b/Assets/UniWebView/Script/UniWebViewToolbarPosition.cs.meta new file mode 100644 index 00000000..3f8363df --- /dev/null +++ b/Assets/UniWebView/Script/UniWebViewToolbarPosition.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9e4c706c92e5e4dc381385bf4edbd3dd +timeCreated: 1496199547 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/Script/UniWebViewTransitionEdge.cs b/Assets/UniWebView/Script/UniWebViewTransitionEdge.cs new file mode 100644 index 00000000..9871428a --- /dev/null +++ b/Assets/UniWebView/Script/UniWebViewTransitionEdge.cs @@ -0,0 +1,43 @@ +// +// UniWebViewTransitionEdge.cs +// Created by Wang Wei(@onevcat) on 2017-05-04. +// +// 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. + +/// +/// An enum to identify transition edge from or to when the UniWebView +/// transition happens. You can specify an edge in Show() or Hide() methods of web view. +/// +public enum UniWebViewTransitionEdge +{ + /// + /// No transition when showing or hiding. + /// + None = 0, + /// + /// Transit the web view from/to top. + /// + Top, + /// + /// Transit the web view from/to left. + /// + Left, + /// + /// Transit the web view from/to bottom. + /// + Bottom, + /// + /// Transit the web view from/to right. + /// + Right +} diff --git a/Assets/UniWebView/Script/UniWebViewTransitionEdge.cs.meta b/Assets/UniWebView/Script/UniWebViewTransitionEdge.cs.meta new file mode 100644 index 00000000..704be0a2 --- /dev/null +++ b/Assets/UniWebView/Script/UniWebViewTransitionEdge.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1256e7eea8f184fae9b700f8f78e014c +timeCreated: 1493888384 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniWebView/UniWebView-CSharp.asmdef b/Assets/UniWebView/UniWebView-CSharp.asmdef new file mode 100644 index 00000000..fde895a6 --- /dev/null +++ b/Assets/UniWebView/UniWebView-CSharp.asmdef @@ -0,0 +1,13 @@ +{ + "name": "UniWebView-CSharp", + "references": [], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Assets/UniWebView/UniWebView-CSharp.asmdef.meta b/Assets/UniWebView/UniWebView-CSharp.asmdef.meta new file mode 100644 index 00000000..de361b10 --- /dev/null +++ b/Assets/UniWebView/UniWebView-CSharp.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 4ca033ee547ec451c8a2d3c33d7620ad +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/test.cs b/Assets/test.cs new file mode 100644 index 00000000..dc64109b --- /dev/null +++ b/Assets/test.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class test : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + var webView = gameObject.GetComponent(); + webView.Frame = new Rect(0, 0, Screen.width, Screen.height); + + // Load a URL. + webView.Load("http://192.168.0.101:3081"); + + // Show it. + webView.Show(); + + webView.ReferenceRectTransform = GetComponent(); + webView.OnMessageReceived -= FromJs; + webView.OnMessageReceived += FromJs; + } + + private void FromJs(UniWebView webView, UniWebViewMessage message) + { + if (message.Path.Equals("Test")) + { + transform.Find("Text").GetComponent().text = message.Args["msg"]; + } + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/test.cs.meta b/Assets/test.cs.meta new file mode 100644 index 00000000..132a8fff --- /dev/null +++ b/Assets/test.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 87a02f5a9d8ce2e43b46b9bbbc2a04c4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: