Implement opening external package link.
This commit is contained in:
13
Assets/Cryville/Common/Unity/UrlOpener.cs
Normal file
13
Assets/Cryville/Common/Unity/UrlOpener.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace Cryville.Common.Unity {
|
||||
public static class UrlOpener {
|
||||
public static void Open(string url) {
|
||||
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
|
||||
System.Diagnostics.Process.Start(url);
|
||||
#elif UNITY_ANDROID
|
||||
new UnityEngine.AndroidJavaClass("world.cryville.common.unity.UrlOpener").CallStatic("open", new object[] { url });
|
||||
#else
|
||||
#error Unknown platform.
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Cryville/Common/Unity/UrlOpener.cs.meta
Normal file
11
Assets/Cryville/Common/Unity/UrlOpener.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c827ee181de8c51499777e5a822981b8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
17
Assets/Cryville/Common/Unity/UrlOpener.java
Normal file
17
Assets/Cryville/Common/Unity/UrlOpener.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package world.cryville.common.unity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import com.unity3d.player.UnityPlayer;
|
||||
import com.unity3d.player.UnityPlayerActivity;
|
||||
|
||||
public final class UrlOpener {
|
||||
private UrlOpener() { }
|
||||
|
||||
static UnityPlayerActivity activity;
|
||||
|
||||
public static void open(String url) {
|
||||
if (activity == null) activity = (UnityPlayerActivity)UnityPlayer.currentActivity;
|
||||
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
|
||||
}
|
||||
}
|
32
Assets/Cryville/Common/Unity/UrlOpener.java.meta
Normal file
32
Assets/Cryville/Common/Unity/UrlOpener.java.meta
Normal file
@@ -0,0 +1,32 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2d08ba79acb0564b9802b57dbc2f8d3
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -77,7 +77,10 @@ namespace Cryville.Crtr.Network {
|
||||
}
|
||||
}
|
||||
if (totalDiffSize == 0 || totalDiffSize >= fullPackage.size) {
|
||||
Dialog.ShowAndWait(string.Format("A new version is available: {0}\nYou have to download the full package.\nOpen the download link now?", latestVersion.name), "Yes", "No");
|
||||
// TODO Check if external
|
||||
if (Dialog.ShowAndWait(string.Format("A new version is available: {0}\nYou have to download the full package.\nOpen the download link now?", latestVersion.name), "Yes", "No") == 0) {
|
||||
UrlOpener.Open(fullPackage.url);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Dialog.ShowAndWait(string.Format("A new version is available: {0}\nDo you want to update?", latestVersion.name), "Yes", "No");
|
||||
|
Reference in New Issue
Block a user