Implement opening external package link.

This commit is contained in:
2023-07-03 01:10:45 +08:00
parent 864ea91be0
commit 83b9c27e94
5 changed files with 77 additions and 1 deletions

View 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
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c827ee181de8c51499777e5a822981b8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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)));
}
}

View 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:

View File

@@ -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");