移动端浏览器
This commit is contained in:
parent
5c2c22b675
commit
4260cf05d3
8
Assets/Editor/UniWebView.meta
Normal file
8
Assets/Editor/UniWebView.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cbfad999c612c244f9a6c609a97122ca
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
20
Assets/Editor/UniWebView/settings.asset
Normal file
20
Assets/Editor/UniWebView/settings.asset
Normal file
@ -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
|
||||||
8
Assets/Editor/UniWebView/settings.asset.meta
Normal file
8
Assets/Editor/UniWebView/settings.asset.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 580a44b4404956543a86c106381eae18
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Plugins/Android/UniWebView.aar
Normal file
BIN
Assets/Plugins/Android/UniWebView.aar
Normal file
Binary file not shown.
33
Assets/Plugins/Android/UniWebView.aar.meta
Normal file
33
Assets/Plugins/Android/UniWebView.aar.meta
Normal file
@ -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:
|
||||||
@ -8,6 +8,8 @@ dependencies {
|
|||||||
implementation files ("libs/unity-classes.jar")
|
implementation files ("libs/unity-classes.jar")
|
||||||
implementation files ("libs/unityandroidbluetoothlelib.jar")
|
implementation files ("libs/unityandroidbluetoothlelib.jar")
|
||||||
implementation files ('libs/PowerFunAndroidPlugin-release.aar')
|
implementation files ('libs/PowerFunAndroidPlugin-release.aar')
|
||||||
|
implementation files ('libs/UniWebView.aar')
|
||||||
|
|
||||||
implementation ('com.mapbox.maps:android:10.2.0-beta.1'){
|
implementation ('com.mapbox.maps:android:10.2.0-beta.1'){
|
||||||
exclude group: 'group_name', module: 'module_name'
|
exclude group: 'group_name', module: 'module_name'
|
||||||
}
|
}
|
||||||
|
|||||||
46
Assets/Plugins/UniWebView.bundle.meta
Normal file
46
Assets/Plugins/UniWebView.bundle.meta
Normal file
@ -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:
|
||||||
9
Assets/Plugins/UniWebView.bundle/Contents.meta
Normal file
9
Assets/Plugins/UniWebView.bundle/Contents.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 19150ffd969374afd9b181cd8c71f662
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1536156019
|
||||||
|
licenseType: Store
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
48
Assets/Plugins/UniWebView.bundle/Contents/Info.plist
Normal file
48
Assets/Plugins/UniWebView.bundle/Contents/Info.plist
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>BuildMachineOSBuild</key>
|
||||||
|
<string>20G224</string>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>en</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>UniWebView</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>com.onevcat.UniWebViewMac</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>UniWebView</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>BNDL</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>CFBundleSupportedPlatforms</key>
|
||||||
|
<array>
|
||||||
|
<string>MacOSX</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1</string>
|
||||||
|
<key>DTCompiler</key>
|
||||||
|
<string>com.apple.compilers.llvm.clang.1_0</string>
|
||||||
|
<key>DTPlatformBuild</key>
|
||||||
|
<string>13A1030d</string>
|
||||||
|
<key>DTPlatformName</key>
|
||||||
|
<string>macosx</string>
|
||||||
|
<key>DTPlatformVersion</key>
|
||||||
|
<string>12.0</string>
|
||||||
|
<key>DTSDKBuild</key>
|
||||||
|
<string>21A344</string>
|
||||||
|
<key>DTSDKName</key>
|
||||||
|
<string>macosx12.0</string>
|
||||||
|
<key>DTXcode</key>
|
||||||
|
<string>1310</string>
|
||||||
|
<key>DTXcodeBuild</key>
|
||||||
|
<string>13A1030d</string>
|
||||||
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
<string>10.10</string>
|
||||||
|
<key>NSHumanReadableCopyright</key>
|
||||||
|
<string>Copyright © 2017年 OneV's Den. All rights reserved.</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6ed4d1ad77ba246f0aa50cb883ca2973
|
||||||
|
timeCreated: 1536156020
|
||||||
|
licenseType: Store
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
9
Assets/Plugins/UniWebView.bundle/Contents/MacOS.meta
Normal file
9
Assets/Plugins/UniWebView.bundle/Contents/MacOS.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 495312126946747a3b197461eaff9687
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1536156020
|
||||||
|
licenseType: Store
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Plugins/UniWebView.bundle/Contents/MacOS/UniWebView
Normal file
BIN
Assets/Plugins/UniWebView.bundle/Contents/MacOS/UniWebView
Normal file
Binary file not shown.
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0168f4971f50d488e959c40d05b94c59
|
||||||
|
timeCreated: 1536156020
|
||||||
|
licenseType: Store
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 80fcb824c01d44613803213f4b1ed096
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1536156020
|
||||||
|
licenseType: Store
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,115 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>files</key>
|
||||||
|
<dict/>
|
||||||
|
<key>files2</key>
|
||||||
|
<dict/>
|
||||||
|
<key>rules</key>
|
||||||
|
<dict>
|
||||||
|
<key>^Resources/</key>
|
||||||
|
<true/>
|
||||||
|
<key>^Resources/.*\.lproj/</key>
|
||||||
|
<dict>
|
||||||
|
<key>optional</key>
|
||||||
|
<true/>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>1000</real>
|
||||||
|
</dict>
|
||||||
|
<key>^Resources/.*\.lproj/locversion.plist$</key>
|
||||||
|
<dict>
|
||||||
|
<key>omit</key>
|
||||||
|
<true/>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>1100</real>
|
||||||
|
</dict>
|
||||||
|
<key>^Resources/Base\.lproj/</key>
|
||||||
|
<dict>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>1010</real>
|
||||||
|
</dict>
|
||||||
|
<key>^version.plist$</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
<key>rules2</key>
|
||||||
|
<dict>
|
||||||
|
<key>.*\.dSYM($|/)</key>
|
||||||
|
<dict>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>11</real>
|
||||||
|
</dict>
|
||||||
|
<key>^(.*/)?\.DS_Store$</key>
|
||||||
|
<dict>
|
||||||
|
<key>omit</key>
|
||||||
|
<true/>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>2000</real>
|
||||||
|
</dict>
|
||||||
|
<key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key>
|
||||||
|
<dict>
|
||||||
|
<key>nested</key>
|
||||||
|
<true/>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>10</real>
|
||||||
|
</dict>
|
||||||
|
<key>^.*</key>
|
||||||
|
<true/>
|
||||||
|
<key>^Info\.plist$</key>
|
||||||
|
<dict>
|
||||||
|
<key>omit</key>
|
||||||
|
<true/>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>20</real>
|
||||||
|
</dict>
|
||||||
|
<key>^PkgInfo$</key>
|
||||||
|
<dict>
|
||||||
|
<key>omit</key>
|
||||||
|
<true/>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>20</real>
|
||||||
|
</dict>
|
||||||
|
<key>^Resources/</key>
|
||||||
|
<dict>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>20</real>
|
||||||
|
</dict>
|
||||||
|
<key>^Resources/.*\.lproj/</key>
|
||||||
|
<dict>
|
||||||
|
<key>optional</key>
|
||||||
|
<true/>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>1000</real>
|
||||||
|
</dict>
|
||||||
|
<key>^Resources/.*\.lproj/locversion.plist$</key>
|
||||||
|
<dict>
|
||||||
|
<key>omit</key>
|
||||||
|
<true/>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>1100</real>
|
||||||
|
</dict>
|
||||||
|
<key>^Resources/Base\.lproj/</key>
|
||||||
|
<dict>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>1010</real>
|
||||||
|
</dict>
|
||||||
|
<key>^[^/]+$</key>
|
||||||
|
<dict>
|
||||||
|
<key>nested</key>
|
||||||
|
<true/>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>10</real>
|
||||||
|
</dict>
|
||||||
|
<key>^embedded\.provisionprofile$</key>
|
||||||
|
<dict>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>20</real>
|
||||||
|
</dict>
|
||||||
|
<key>^version\.plist$</key>
|
||||||
|
<dict>
|
||||||
|
<key>weight</key>
|
||||||
|
<real>20</real>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f0a1c562a4f234a5c80db8830befc067
|
||||||
|
timeCreated: 1536156020
|
||||||
|
licenseType: Store
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Plugins/iOS/libUniWebView.a
Normal file
BIN
Assets/Plugins/iOS/libUniWebView.a
Normal file
Binary file not shown.
123
Assets/Plugins/iOS/libUniWebView.a.meta
Normal file
123
Assets/Plugins/iOS/libUniWebView.a.meta
Normal file
@ -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:
|
||||||
File diff suppressed because it is too large
Load Diff
@ -18,7 +18,7 @@ public delegate void ChangeLanguageDelegate();
|
|||||||
|
|
||||||
public static class App
|
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;
|
public static string AppVersion = Application.version;
|
||||||
|
|
||||||
|
|||||||
9
Assets/UniWebView.meta
Normal file
9
Assets/UniWebView.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 92454175c62504ab5bf7128917b56362
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1490878496
|
||||||
|
licenseType: Store
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
1384
Assets/UniWebView/CHANGELOG.md
Normal file
1384
Assets/UniWebView/CHANGELOG.md
Normal file
File diff suppressed because it is too large
Load Diff
8
Assets/UniWebView/CHANGELOG.md.meta
Normal file
8
Assets/UniWebView/CHANGELOG.md.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f7ee8c3eb642344b08f4ceeb53d70cd1
|
||||||
|
timeCreated: 1497057465
|
||||||
|
licenseType: Store
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
9
Assets/UniWebView/Demo.meta
Normal file
9
Assets/UniWebView/Demo.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 565d674726c3d499cade2709dd955ad0
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1536753564
|
||||||
|
licenseType: Store
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
337
Assets/UniWebView/Demo/UniWebViewDemo.unity
Normal file
337
Assets/UniWebView/Demo/UniWebViewDemo.unity
Normal file
@ -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}
|
||||||
8
Assets/UniWebView/Demo/UniWebViewDemo.unity.meta
Normal file
8
Assets/UniWebView/Demo/UniWebViewDemo.unity.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 938c077f40a814d4584ce2ad17947cf3
|
||||||
|
timeCreated: 1536753573
|
||||||
|
licenseType: Store
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/UniWebView/Editor.meta
Normal file
8
Assets/UniWebView/Editor.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5f0047c1c8c8348de9d66b0496b353e1
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
142
Assets/UniWebView/Editor/AndroidManifest.cs
Normal file
142
Assets/UniWebView/Editor/AndroidManifest.cs
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/UniWebView/Editor/AndroidManifest.cs.meta
Normal file
11
Assets/UniWebView/Editor/AndroidManifest.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d09054fcc76964295a49868566075973
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
344
Assets/UniWebView/Editor/BuildGradle.cs
Normal file
344
Assets/UniWebView/Editor/BuildGradle.cs
Normal file
@ -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<UniWebViewGradleNode> m_children = new List<UniWebViewGradleNode>();
|
||||||
|
protected UniWebViewGradleNode m_parent;
|
||||||
|
protected String m_name;
|
||||||
|
public UniWebViewGradleNode PARENT
|
||||||
|
{
|
||||||
|
get { return m_parent; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string NAME
|
||||||
|
{
|
||||||
|
get { return m_name; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UniWebViewGradleNode> CHILDREN
|
||||||
|
{
|
||||||
|
get { return m_children; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public UniWebViewGradleNode(string name, UniWebViewGradleNode parent = null)
|
||||||
|
{
|
||||||
|
m_parent = parent;
|
||||||
|
m_name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Each(Action<UniWebViewGradleNode> 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<UniWebViewGradleNode>();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加子节点
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="content"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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<m_children.Count;i++)
|
||||||
|
{
|
||||||
|
if (!(m_children[i] is UniWebViewGradleContentNode)) continue;
|
||||||
|
if(m_children[i].m_name.Contains(contentPattern))
|
||||||
|
{
|
||||||
|
m_children.RemoveAt(i);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class UniWebViewGradleContentNode : UniWebViewGradleNode
|
||||||
|
{
|
||||||
|
public UniWebViewGradleContentNode(String content, UniWebViewGradleNode parent) : base(content, parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetContent(string content)
|
||||||
|
{
|
||||||
|
m_name = content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class UniWebViewGradleCommentNode : UniWebViewGradleNode
|
||||||
|
{
|
||||||
|
public UniWebViewGradleCommentNode(String content, UniWebViewGradleNode parent) : base(content, parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetComment()
|
||||||
|
{
|
||||||
|
return m_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
11
Assets/UniWebView/Editor/BuildGradle.cs.meta
Normal file
11
Assets/UniWebView/Editor/BuildGradle.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4a73a3268e19f44f7be818c5db9af457
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
32
Assets/UniWebView/Editor/GradleProperty.cs
Normal file
32
Assets/UniWebView/Editor/GradleProperty.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
|
||||||
|
public class UniWebViewGradlePropertyPatcher {
|
||||||
|
public static void Patch(string filePath) {
|
||||||
|
string[] lines = File.ReadAllLines(filePath);
|
||||||
|
|
||||||
|
bool hasAndroidXProperty = lines.Any(text => 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/UniWebView/Editor/GradleProperty.cs.meta
Normal file
11
Assets/UniWebView/Editor/GradleProperty.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 62bf94600ac0f42c09fc261d7ab19e12
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
15
Assets/UniWebView/Editor/UniWebView-CSharp.Editor.asmdef
Normal file
15
Assets/UniWebView/Editor/UniWebView-CSharp.Editor.asmdef
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "UniWebView-CSharp.Editor",
|
||||||
|
"references": [],
|
||||||
|
"includePlatforms": [
|
||||||
|
"Editor"
|
||||||
|
],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b6d0e5b49a073436cbcd56804553ee20
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
114
Assets/UniWebView/Editor/UniWebViewEditorSettings.cs
Normal file
114
Assets/UniWebView/Editor/UniWebViewEditorSettings.cs
Normal file
@ -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<UniWebViewEditorSettings>(assetPath);
|
||||||
|
|
||||||
|
if (settings == null) {
|
||||||
|
settings = ScriptableObject.CreateInstance<UniWebViewEditorSettings>();
|
||||||
|
|
||||||
|
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--;
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/UniWebView/Editor/UniWebViewEditorSettings.cs.meta
Normal file
11
Assets/UniWebView/Editor/UniWebViewEditorSettings.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a403a09e241a0480a957591ea60fb785
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
116
Assets/UniWebView/Editor/UniWebViewPostBuildProcessor.cs
Normal file
116
Assets/UniWebView/Editor/UniWebViewPostBuildProcessor.cs
Normal file
@ -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> 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("<UniWebView> 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("<UniWebView> Updated Kotlin dependency in build.gradle.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add browser package
|
||||||
|
if (settings.addsAndroidBrowser) {
|
||||||
|
dependenciesNode.ReplaceContenOrAddStartsWith(browserPrefix, browserPrefix + browserVersion);
|
||||||
|
Debug.Log("<UniWebView> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 59d4a8d85c95843719d8b9df823c3da3
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
9
Assets/UniWebView/Interface.meta
Normal file
9
Assets/UniWebView/Interface.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dc0f52a2d219347b1a6390b753d6ac97
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1491898971
|
||||||
|
licenseType: Store
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
402
Assets/UniWebView/Interface/UniWebViewAndroid.cs
Normal file
402
Assets/UniWebView/Interface/UniWebViewAndroid.cs
Normal file
@ -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<UniWebViewAndroidStaticListener>();
|
||||||
|
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<string>("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<bool>("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<bool>("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<bool>("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<string>("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<string>("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<float>("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<bool>("canGoBack", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool CanGoForward(string name) {
|
||||||
|
CheckPlatform();
|
||||||
|
return plugin.CallStatic<bool>("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<float>("screenWidth");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float NativeScreenHeight() {
|
||||||
|
CheckPlatform();
|
||||||
|
return plugin.CallStatic<float>("screenHeight");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetDownloadEventForContextMenuEnabled(string name, bool enabled) {
|
||||||
|
CheckPlatform();
|
||||||
|
plugin.CallStatic("setDownloadEventForContextMenuEnabled", name, enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsSafeBrowsingSupported() {
|
||||||
|
CheckPlatform();
|
||||||
|
return plugin.CallStatic<bool>("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
|
||||||
12
Assets/UniWebView/Interface/UniWebViewAndroid.cs.meta
Normal file
12
Assets/UniWebView/Interface/UniWebViewAndroid.cs.meta
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5a1d3cecc27d64565835e14b493c935b
|
||||||
|
timeCreated: 1490880130
|
||||||
|
licenseType: Store
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -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
|
||||||
@ -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:
|
||||||
687
Assets/UniWebView/Interface/UniWebViewCocoa.cs
Normal file
687
Assets/UniWebView/Interface/UniWebViewCocoa.cs
Normal file
@ -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
|
||||||
12
Assets/UniWebView/Interface/UniWebViewCocoa.cs.meta
Normal file
12
Assets/UniWebView/Interface/UniWebViewCocoa.cs.meta
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2e905ba0b47304f4cbf9e3e3345f84eb
|
||||||
|
timeCreated: 1492400358
|
||||||
|
licenseType: Store
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
89
Assets/UniWebView/Interface/UniWebViewPlaceholder.cs
Normal file
89
Assets/UniWebView/Interface/UniWebViewPlaceholder.cs
Normal file
@ -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
|
||||||
12
Assets/UniWebView/Interface/UniWebViewPlaceholder.cs.meta
Normal file
12
Assets/UniWebView/Interface/UniWebViewPlaceholder.cs.meta
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0b3bad20d12b1433ab8927c3effc605b
|
||||||
|
timeCreated: 1497403102
|
||||||
|
licenseType: Store
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
9
Assets/UniWebView/Prefab.meta
Normal file
9
Assets/UniWebView/Prefab.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d5d657f2ee1114e20bccaace74235a99
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1491898971
|
||||||
|
licenseType: Store
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
57
Assets/UniWebView/Prefab/UniWebView.prefab
Normal file
57
Assets/UniWebView/Prefab/UniWebView.prefab
Normal file
@ -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}
|
||||||
9
Assets/UniWebView/Prefab/UniWebView.prefab.meta
Normal file
9
Assets/UniWebView/Prefab/UniWebView.prefab.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7e3f16a6f6303419cbd9837f6c746de4
|
||||||
|
timeCreated: 1496204510
|
||||||
|
licenseType: Store
|
||||||
|
NativeFormatImporter:
|
||||||
|
mainObjectFileID: 100100000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
46
Assets/UniWebView/Prefab/UniWebViewSafeBrowsing.prefab
Normal file
46
Assets/UniWebView/Prefab/UniWebViewSafeBrowsing.prefab
Normal file
@ -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:
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2d6c4899a63004f16bb4f791176f4ad3
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
30
Assets/UniWebView/README.txt
Normal file
30
Assets/UniWebView/README.txt
Normal file
@ -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.
|
||||||
8
Assets/UniWebView/README.txt.meta
Normal file
8
Assets/UniWebView/README.txt.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 95440ce70c5e14d6e96e166c45f7cf6d
|
||||||
|
timeCreated: 1499302025
|
||||||
|
licenseType: Store
|
||||||
|
TextScriptImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
9
Assets/UniWebView/Script.meta
Normal file
9
Assets/UniWebView/Script.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b34f36f9836464e04893f632434d0862
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1491898971
|
||||||
|
licenseType: Store
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
1739
Assets/UniWebView/Script/UniWebView.cs
Normal file
1739
Assets/UniWebView/Script/UniWebView.cs
Normal file
File diff suppressed because it is too large
Load Diff
12
Assets/UniWebView/Script/UniWebView.cs.meta
Normal file
12
Assets/UniWebView/Script/UniWebView.cs.meta
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 598e18fb001004a81960f552978ecf4e
|
||||||
|
timeCreated: 1491898971
|
||||||
|
licenseType: Store
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -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.
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constants indicating how safe area insets are added to the adjusted content inset.
|
||||||
|
/// This is only for iOS.
|
||||||
|
/// </summary>
|
||||||
|
public enum UniWebViewContentInsetAdjustmentBehavior
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Automatically adjust the scroll view insets.
|
||||||
|
/// </summary>
|
||||||
|
Automatic = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adjust the insets only in the scrollable directions.
|
||||||
|
/// </summary>
|
||||||
|
ScrollableAxes = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Do not adjust the scroll view insets.
|
||||||
|
/// </summary>
|
||||||
|
Never = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Always include the safe area insets in the content adjustment.
|
||||||
|
/// </summary>
|
||||||
|
Always = 3
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dc6b999829de442f2aa381a8ff78a917
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
32
Assets/UniWebView/Script/UniWebViewDownloadMatchingType.cs
Normal file
32
Assets/UniWebView/Script/UniWebViewDownloadMatchingType.cs
Normal file
@ -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.
|
||||||
|
//
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The matching type used when UniWebView determines whether to download from a URL or MIME type.
|
||||||
|
/// </summary>
|
||||||
|
public enum UniWebViewDownloadMatchingType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Matches exact the whole value.
|
||||||
|
/// </summary>
|
||||||
|
ExactValue = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// Uses the value as a regular expression.
|
||||||
|
/// </summary>
|
||||||
|
RegularExpression = 2
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0ba73f1cc351846878c5731b4e22b132
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
67
Assets/UniWebView/Script/UniWebViewHelper.cs
Normal file
67
Assets/UniWebView/Script/UniWebViewHelper.cs
Normal file
@ -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;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Provides some helper utility methods for UniWebView.
|
||||||
|
/// </summary>
|
||||||
|
public class UniWebViewHelper {
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// <param name="path">The relative path to the Assets/StreamingAssets of your file.
|
||||||
|
/// For example, if you placed a html file under Assets/StreamingAssets/www/index.html, you should pass `www/index.html` as parameter.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>The path you could use as the url for the web view.</returns>
|
||||||
|
public static string StreamingAssetURLForPath(string path)
|
||||||
|
{
|
||||||
|
#if (UNITY_EDITOR_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
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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`.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">
|
||||||
|
/// The relative path to the persistent data path of your file.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>The path you could use as the url for the web view.</returns>
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Assets/UniWebView/Script/UniWebViewHelper.cs.meta
Normal file
12
Assets/UniWebView/Script/UniWebViewHelper.cs.meta
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 824ddd9d1592945268d857265662a174
|
||||||
|
timeCreated: 1495373327
|
||||||
|
licenseType: Store
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
120
Assets/UniWebView/Script/UniWebViewLogger.cs
Normal file
120
Assets/UniWebView/Script/UniWebViewLogger.cs
Normal file
@ -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.
|
||||||
|
//
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A leveled logger which could log UniWebView related messages in
|
||||||
|
/// both development environment and final product.
|
||||||
|
/// </summary>
|
||||||
|
public class UniWebViewLogger {
|
||||||
|
/// <summary>
|
||||||
|
/// Logger level.
|
||||||
|
/// </summary>
|
||||||
|
public enum Level {
|
||||||
|
/// <summary>
|
||||||
|
/// Lowest level. When set to `Verbose`, the logger will log out all messages.
|
||||||
|
/// </summary>
|
||||||
|
Verbose = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Debug level. When set to `Debug`, the logger will log out most of messages up to this level.
|
||||||
|
/// </summary>
|
||||||
|
Debug = 10,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Info level. When set to `Info`, the logger will log out up to info messages.
|
||||||
|
/// </summary>
|
||||||
|
Info = 20,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Critical level. When set to `Critical`, the logger will only log out errors or exceptions.
|
||||||
|
/// </summary>
|
||||||
|
Critical = 80,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Off level. When set to `Off`, the logger will log out nothing.
|
||||||
|
/// </summary>
|
||||||
|
Off = 99
|
||||||
|
}
|
||||||
|
|
||||||
|
private static UniWebViewLogger instance;
|
||||||
|
private Level level;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
public static UniWebViewLogger Instance {
|
||||||
|
get {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new UniWebViewLogger(Level.Critical);
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Log a verbose message.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">The message to log.</param>
|
||||||
|
public void Verbose(string message) { Log(Level.Verbose, message); }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Log a debug message.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">The message to log.</param>
|
||||||
|
public void Debug(string message) { Log(Level.Debug, message); }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Log an info message.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">The message to log.</param>
|
||||||
|
public void Info(string message) { Log(Level.Info, message); }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Log a critical message.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">The message to log.</param>
|
||||||
|
public void Critical(string message) { Log(Level.Critical, message); }
|
||||||
|
|
||||||
|
private void Log(Level level, string message) {
|
||||||
|
if (level >= this.LogLevel) {
|
||||||
|
var logMessage = "<UniWebView> " + message;
|
||||||
|
if (level == Level.Critical) {
|
||||||
|
UnityEngine.Debug.LogError(logMessage);
|
||||||
|
} else {
|
||||||
|
UnityEngine.Debug.Log(logMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Assets/UniWebView/Script/UniWebViewLogger.cs.meta
Normal file
12
Assets/UniWebView/Script/UniWebViewLogger.cs.meta
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 06ca7a8564d9842ba99c77d43e9ce4f5
|
||||||
|
timeCreated: 1491898971
|
||||||
|
licenseType: Store
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
111
Assets/UniWebView/Script/UniWebViewMessage.cs
Normal file
111
Assets/UniWebView/Script/UniWebViewMessage.cs
Normal file
@ -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
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A structure represents a message from webview.
|
||||||
|
/// </summary>
|
||||||
|
public struct UniWebViewMessage {
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the raw message. It is the original url which initialized this message.
|
||||||
|
/// </summary>
|
||||||
|
public string RawMessage {get; private set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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`.
|
||||||
|
/// </summary>
|
||||||
|
public string Scheme {get; private set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The path of this UniWebViewMessage.
|
||||||
|
/// This will be the decoded value for the path of original url.
|
||||||
|
/// </summary>
|
||||||
|
public string Path {get; private set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, string> Args{get; private set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the `UniWebViewMessage` struct.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rawMessage">Raw message which will be parsed to a UniWebViewMessage.</param>
|
||||||
|
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<string, string>();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Assets/UniWebView/Script/UniWebViewMessage.cs.meta
Normal file
12
Assets/UniWebView/Script/UniWebViewMessage.cs.meta
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0dbdb1ed01b9747a1ad6eb7bcc7b4014
|
||||||
|
timeCreated: 1491898971
|
||||||
|
licenseType: Store
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
196
Assets/UniWebView/Script/UniWebViewNativeListener.cs
Normal file
196
Assets/UniWebView/Script/UniWebViewNativeListener.cs
Normal file
@ -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;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
public class UniWebViewNativeListener: MonoBehaviour {
|
||||||
|
|
||||||
|
private static Dictionary<String, UniWebViewNativeListener> listeners = new Dictionary<String, UniWebViewNativeListener>();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
[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;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Name of current listener. This is a UUID string by which native side could use to find
|
||||||
|
/// the message destination.
|
||||||
|
/// </summary>
|
||||||
|
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<UniWebViewNativeResultPayload>(result);
|
||||||
|
webView.InternalOnPageFinished(payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PageErrorReceived(string result) {
|
||||||
|
UniWebViewLogger.Instance.Info("Page Error Received Event. Result: " + result);
|
||||||
|
var payload = JsonUtility.FromJson<UniWebViewNativeResultPayload>(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<UniWebViewNativeResultPayload>(result);
|
||||||
|
webView.InternalOnAddJavaScriptFinished(payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EvalJavaScriptFinished(string result) {
|
||||||
|
UniWebViewLogger.Instance.Info("Eval JavaScript Finished Event. Result: " + result);
|
||||||
|
|
||||||
|
var payload = JsonUtility.FromJson<UniWebViewNativeResultPayload>(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<UniWebViewNativeResultPayload>(result);
|
||||||
|
webView.InternalOnFileDownloadStarted(payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void FileDownloadFinished(string result) {
|
||||||
|
UniWebViewLogger.Instance.Info("FileDownloadFinished Event. Result: " + result);
|
||||||
|
|
||||||
|
var payload = JsonUtility.FromJson<UniWebViewNativeResultPayload>(result);
|
||||||
|
webView.InternalOnFileDownloadFinished(payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CaptureSnapshotFinished(string result) {
|
||||||
|
UniWebViewLogger.Instance.Info("CaptureSnapshotFinished Event. Result: " + result);
|
||||||
|
|
||||||
|
var payload = JsonUtility.FromJson<UniWebViewNativeResultPayload>(result);
|
||||||
|
webView.InternalOnCaptureSnapshotFinished(payload);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
[System.Serializable]
|
||||||
|
public class UniWebViewNativeResultPayload {
|
||||||
|
/// <summary>
|
||||||
|
/// The identifier bound to this payload. It would be used internally to identify the callback.
|
||||||
|
/// </summary>
|
||||||
|
public string identifier;
|
||||||
|
/// <summary>
|
||||||
|
/// The result code contained in this payload. Generally, "0" means the operation finished without
|
||||||
|
/// problem, while a non-zero value means somethings goes wrong.
|
||||||
|
/// </summary>
|
||||||
|
public string resultCode;
|
||||||
|
/// <summary>
|
||||||
|
/// Return value or data from native. You should look at
|
||||||
|
/// corresponding APIs to know what exactly contained in this.
|
||||||
|
/// </summary>
|
||||||
|
public string data;
|
||||||
|
}
|
||||||
12
Assets/UniWebView/Script/UniWebViewNativeListener.cs.meta
Normal file
12
Assets/UniWebView/Script/UniWebViewNativeListener.cs.meta
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5538b25d1713f4de994dacdc6eaacb95
|
||||||
|
timeCreated: 1491961733
|
||||||
|
licenseType: Store
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
20
Assets/UniWebView/Script/UniWebViewSafeBrowingComponent.cs
Normal file
20
Assets/UniWebView/Script/UniWebViewSafeBrowingComponent.cs
Normal file
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5843488507315421aa0a7d92c0604d10
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
194
Assets/UniWebView/Script/UniWebViewSafeBrowsing.cs
Normal file
194
Assets/UniWebView/Script/UniWebViewSafeBrowsing.cs
Normal file
@ -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;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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`.
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class UniWebViewSafeBrowsing: UnityEngine.Object {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delegate for safe browsing finish event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="browsing">The `UniWebViewSafeBrowsing` object raised this event.</param>
|
||||||
|
public delegate void OnSafeBrowsingFinishedDelegate(UniWebViewSafeBrowsing browsing);
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
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;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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
|
||||||
|
/// <queries>
|
||||||
|
/// <intent>
|
||||||
|
/// <action android:name="android.support.customtabs.action.CustomTabsService" />
|
||||||
|
/// </intent>
|
||||||
|
/// </queries>
|
||||||
|
/// ```
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// Returns `true` if the safe browsing mode is supported and the page will be opened in safe browsing
|
||||||
|
/// mode. Otherwise, `false`.
|
||||||
|
/// </value>
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new `UniWebViewSafeBrowsing` instance with a given URL.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="url">The URL to navigate to. The URL must use the `http` or `https` scheme.</param>
|
||||||
|
/// <returns>A newly created `UniWebViewSafeBrowsing` instance.</returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shows the safe browsing content above current screen.
|
||||||
|
/// </summary>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
public void Dismiss() {
|
||||||
|
#if UNITY_IOS && !UNITY_EDITOR
|
||||||
|
UniWebViewInterface.SafeBrowsingDismiss(listener.Name);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the color for toolbar background in the safe browsing component. The changes are ignored after `Show`
|
||||||
|
/// method is called.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="color">The color to tint the toolbar.</param>
|
||||||
|
public void SetToolbarColor(Color color) {
|
||||||
|
if (!UniWebViewHelper.IsEditor) {
|
||||||
|
UniWebViewInterface.SafeBrowsingSetToolbarColor(listener.Name, color.r, color.g, color.b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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`.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="color">The color to tint the controls on toolbar.</param>
|
||||||
|
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>();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/UniWebView/Script/UniWebViewSafeBrowsing.cs.meta
Normal file
11
Assets/UniWebView/Script/UniWebViewSafeBrowsing.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dca3ba926a98540d3a2bff6312899a75
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
32
Assets/UniWebView/Script/UniWebViewToolbarPosition.cs
Normal file
32
Assets/UniWebView/Script/UniWebViewToolbarPosition.cs
Normal file
@ -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.
|
||||||
|
//
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Toolbar position of webview. You can set the snapping edge for the built-in toolbar in iOS.
|
||||||
|
/// </summary>
|
||||||
|
public enum UniWebViewToolbarPosition
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Top screen edge.
|
||||||
|
/// </summary>
|
||||||
|
Top = 0,
|
||||||
|
/// <summary>
|
||||||
|
/// Bottom screen edge.
|
||||||
|
/// </summary>
|
||||||
|
Bottom
|
||||||
|
}
|
||||||
|
|
||||||
12
Assets/UniWebView/Script/UniWebViewToolbarPosition.cs.meta
Normal file
12
Assets/UniWebView/Script/UniWebViewToolbarPosition.cs.meta
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9e4c706c92e5e4dc381385bf4edbd3dd
|
||||||
|
timeCreated: 1496199547
|
||||||
|
licenseType: Store
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
43
Assets/UniWebView/Script/UniWebViewTransitionEdge.cs
Normal file
43
Assets/UniWebView/Script/UniWebViewTransitionEdge.cs
Normal file
@ -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.
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
public enum UniWebViewTransitionEdge
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// No transition when showing or hiding.
|
||||||
|
/// </summary>
|
||||||
|
None = 0,
|
||||||
|
/// <summary>
|
||||||
|
/// Transit the web view from/to top.
|
||||||
|
/// </summary>
|
||||||
|
Top,
|
||||||
|
/// <summary>
|
||||||
|
/// Transit the web view from/to left.
|
||||||
|
/// </summary>
|
||||||
|
Left,
|
||||||
|
/// <summary>
|
||||||
|
/// Transit the web view from/to bottom.
|
||||||
|
/// </summary>
|
||||||
|
Bottom,
|
||||||
|
/// <summary>
|
||||||
|
/// Transit the web view from/to right.
|
||||||
|
/// </summary>
|
||||||
|
Right
|
||||||
|
}
|
||||||
12
Assets/UniWebView/Script/UniWebViewTransitionEdge.cs.meta
Normal file
12
Assets/UniWebView/Script/UniWebViewTransitionEdge.cs.meta
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1256e7eea8f184fae9b700f8f78e014c
|
||||||
|
timeCreated: 1493888384
|
||||||
|
licenseType: Store
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
13
Assets/UniWebView/UniWebView-CSharp.asmdef
Normal file
13
Assets/UniWebView/UniWebView-CSharp.asmdef
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "UniWebView-CSharp",
|
||||||
|
"references": [],
|
||||||
|
"includePlatforms": [],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
||||||
7
Assets/UniWebView/UniWebView-CSharp.asmdef.meta
Normal file
7
Assets/UniWebView/UniWebView-CSharp.asmdef.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4ca033ee547ec451c8a2d3c33d7620ad
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
39
Assets/test.cs
Normal file
39
Assets/test.cs
Normal file
@ -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<UniWebView>();
|
||||||
|
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<RectTransform>();
|
||||||
|
webView.OnMessageReceived -= FromJs;
|
||||||
|
webView.OnMessageReceived += FromJs;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FromJs(UniWebView webView, UniWebViewMessage message)
|
||||||
|
{
|
||||||
|
if (message.Path.Equals("Test"))
|
||||||
|
{
|
||||||
|
transform.Find("Text").GetComponent<Text>().text = message.Args["msg"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/test.cs.meta
Normal file
11
Assets/test.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 87a02f5a9d8ce2e43b46b9bbbc2a04c4
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Loading…
x
Reference in New Issue
Block a user