diff --git a/Assets/Mirror/Hosting/Edgegap/Dockerfile b/Assets/Mirror/Hosting/Edgegap/Dockerfile deleted file mode 100644 index 258a141dc..000000000 --- a/Assets/Mirror/Hosting/Edgegap/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM ubuntu:bionic - -ARG DEBIAN_FRONTEND=noninteractive - -COPY Builds/EdgegapServer /root/build/ - -WORKDIR /root/ - -RUN chmod +x /root/build/ServerBuild - -RUN apt-get update && \ - apt-get install -y ca-certificates && \ - apt-get clean && \ - update-ca-certificates - -ENTRYPOINT [ "/root/build/ServerBuild", "-batchmode", "-nographics"] diff --git a/Assets/Mirror/Hosting/Edgegap/Dockerfile.meta b/Assets/Mirror/Hosting/Edgegap/Dockerfile.meta deleted file mode 100644 index 654f29901..000000000 --- a/Assets/Mirror/Hosting/Edgegap/Dockerfile.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 78b80371aabba1d48aac39ec7ccfe7c5 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Mirror/Hosting/Edgegap/Editor/Dockerfile b/Assets/Mirror/Hosting/Edgegap/Editor/Dockerfile index 3d9e3d02d..a621ec396 100644 --- a/Assets/Mirror/Hosting/Edgegap/Editor/Dockerfile +++ b/Assets/Mirror/Hosting/Edgegap/Editor/Dockerfile @@ -1,8 +1,9 @@ FROM ubuntu:22.04 ARG DEBIAN_FRONTEND=noninteractive +ARG SERVER_BUILD_PATH=Builds/EdgegapServer -COPY Builds/EdgegapServer /root/build/ +COPY ${SERVER_BUILD_PATH} /root/build/ WORKDIR /root/ @@ -13,4 +14,4 @@ RUN apt-get update && \ apt-get clean && \ update-ca-certificates -ENTRYPOINT [ "/root/build/ServerBuild", "-batchmode", "-nographics"] +CMD [ "/root/build/ServerBuild", "-batchmode", "-nographics", "$UNITY_COMMANDLINE_ARGS"] diff --git a/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapWindowMetadata.cs b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapWindowMetadata.cs index fdeeede78..9943d0919 100755 --- a/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapWindowMetadata.cs +++ b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapWindowMetadata.cs @@ -63,7 +63,7 @@ public enum LogLevel public const string EDGEGAP_GET_A_TOKEN_URL = "https://app.edgegap.com/?oneClick=true"; public const string EDGEGAP_ADD_MORE_GAME_SERVERS_URL = "https://edgegap.com/resources/contact"; public const string EDGEGAP_DOC_BTN_HOW_TO_LOGIN_VIA_CLI_URL = "https://docs.edgegap.com/docs/container/edgegap-container-registry/#getting-your-credentials"; - private const string DEFAULT_UTM_SOURCE_TAG = "partner_mirror_assetstore_unity"; + private const string DEFAULT_UTM_SOURCE_TAG = "partner_mirror_source_unity"; private const string DEFAULT_UTM_MEDIUM_TAG = "servers_quickstart_plugin"; private const string DEFAULT_UTM_CONTENT_TAG = "plugin_button"; public const string DEFAULT_UTM_TAGS = "utm_source=" + DEFAULT_UTM_SOURCE_TAG + diff --git a/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapWindowV2.cs b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapWindowV2.cs index d425131b4..bc1006161 100755 --- a/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapWindowV2.cs +++ b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapWindowV2.cs @@ -112,7 +112,8 @@ public class EdgegapWindowV2 : EditorWindow Path.GetDirectoryName(AssetDatabase.GetAssetPath(MonoScript.FromScriptableObject(this))); // END MIRROR CHANGE internal string ProjectRootPath => Directory.GetCurrentDirectory(); - internal string DockerFilePath => $"{Directory.GetParent(Directory.GetFiles(ProjectRootPath, GetType().Name + ".cs", SearchOption.AllDirectories)[0]).FullName}{Path.DirectorySeparatorChar}Dockerfile"; + internal string ThisScriptPath => Directory.GetFiles(ProjectRootPath, GetType().Name + ".cs", SearchOption.AllDirectories)[0]; + internal string DockerFilePath => $"{Directory.GetParent(ThisScriptPath).FullName}{Path.DirectorySeparatorChar}Dockerfile"; [MenuItem("Tools/Edgegap Hosting")] // MIRROR CHANGE: more obvious title public static void ShowEdgegapToolWindow() @@ -545,7 +546,11 @@ private void debugEnableAllGroups() _containerCustomRegistryWrapper.SetEnabled(true); } - private void onApiTokenVerifyBtnClick() => _ = verifyApiTokenGetRegistryCredsAsync(); + private void onApiTokenVerifyBtnClick() + { + _ = verifyApiTokenGetRegistryCredsAsync(); + _ = checkForUpdates(); + } private void onApiTokenGetBtnClick() => openGetApiTokenWebsite(); /// Process UI + validation before/after API logic @@ -915,6 +920,24 @@ private string getBase64StrFromSprite(Sprite sprite, int maxKbSize = 200) } } + /// + /// Fetch latest github release and compare with local package.json version + /// + private async Task checkForUpdates() + { + // get local package.json version + DirectoryInfo thisScriptDir = new DirectoryInfo(ThisScriptPath); + PackageJSON local = PackageJSON.PackageJSONFromJSON($"{thisScriptDir.Parent.Parent.ToString()}{Path.DirectorySeparatorChar}package.json"); + + // get latest release from github repository + string releaseJSON = await GithubRelease.GithubReleaseFromAPI(); + GithubRelease latest = GithubRelease.GithubReleaseFromJSON(releaseJSON); + + if (local.version != latest.name) { + Debug.LogWarning($"Please update your Edgegap Quickstart plugin - local version `{local.version}` < latest version `{latest.name}`. See https://github.com/edgegap/edgegap-unity-plugin."); + } + } + /// /// Verifies token => apps/container groups -> gets registry creds (if any). /// TODO: UX - Show loading spinner. diff --git a/Assets/Mirror/Hosting/Edgegap/Editor/GithubRelease.cs b/Assets/Mirror/Hosting/Edgegap/Editor/GithubRelease.cs new file mode 100644 index 000000000..2efad1738 --- /dev/null +++ b/Assets/Mirror/Hosting/Edgegap/Editor/GithubRelease.cs @@ -0,0 +1,31 @@ +using System; +using System.Net.Http; +using System.Threading.Tasks; +using UnityEngine; + +namespace Edgegap.Editor +{ + [Serializable] + public class GithubRelease + { + public string name; + + public static async Task GithubReleaseFromAPI() + { + HttpClient http = new HttpClient(); + http.DefaultRequestHeaders.Add("Accept", "application/vnd.github+json"); + http.DefaultRequestHeaders.Add("X-GitHub-Api-Version", "2022-11-28"); + http.DefaultRequestHeaders.Add("User-Agent", "Unity"); + http.Timeout = TimeSpan.FromSeconds(30); + + HttpResponseMessage response = await http.GetAsync("https://api.github.com/repos/edgegap/edgegap-unity-plugin/releases/latest").ConfigureAwait(false); + + return response.IsSuccessStatusCode ? await response.Content.ReadAsStringAsync() : "{}"; + } + + public static GithubRelease GithubReleaseFromJSON(string json) + { + return JsonUtility.FromJson(json); + } + } +} \ No newline at end of file diff --git a/Assets/Mirror/Hosting/Edgegap/Editor/GithubRelease.cs.meta b/Assets/Mirror/Hosting/Edgegap/Editor/GithubRelease.cs.meta new file mode 100644 index 000000000..77d150c38 --- /dev/null +++ b/Assets/Mirror/Hosting/Edgegap/Editor/GithubRelease.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6ef365e2acd5a5044a4a14fa83c7d9b9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirror/Hosting/Edgegap/Editor/PackageJSON.cs b/Assets/Mirror/Hosting/Edgegap/Editor/PackageJSON.cs new file mode 100644 index 000000000..9b0e06534 --- /dev/null +++ b/Assets/Mirror/Hosting/Edgegap/Editor/PackageJSON.cs @@ -0,0 +1,37 @@ +using System; +using System.IO; +using UnityEngine; + +namespace Edgegap.Editor +{ + [Serializable] + public class PackageJSON + { + [Serializable] + public struct Author + { + public string name; + public string email; + public string url; + } + + public string name; + public string version; + public string displayName; + public string description; + public string unity; + public string unityRelease; + public string documentationUrl; + public string changelogUrl; + public string licensesUrl; + + public Author author; + + // dependencies omitted since JsonUtility doesn't support dictionaries + + public static PackageJSON PackageJSONFromJSON(string path) + { + return JsonUtility.FromJson(File.ReadAllText(path)); + } + } +} \ No newline at end of file diff --git a/Assets/Mirror/Hosting/Edgegap/Editor/PackageJSON.cs.meta b/Assets/Mirror/Hosting/Edgegap/Editor/PackageJSON.cs.meta new file mode 100644 index 000000000..f0382d94b --- /dev/null +++ b/Assets/Mirror/Hosting/Edgegap/Editor/PackageJSON.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e8abfa078881a944a81ac3bcc8e5e0f4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirror/Hosting/Edgegap/README.md b/Assets/Mirror/Hosting/Edgegap/README.md index 129829ea6..638be6ea2 100644 --- a/Assets/Mirror/Hosting/Edgegap/README.md +++ b/Assets/Mirror/Hosting/Edgegap/README.md @@ -42,15 +42,25 @@ This plugin does not need to be included in your builds, as it's only a developm ## Other sources The only other official distribution channels for this plugin are: -- [Mirror Networking samples](https://mirror-networking.gitbook.io/docs/hosting/edgegap-hosting-plugin-guide) -- [Fish Networking samples](https://fish-networking.gitbook.io/docs/manual/server-hosting/edgegap-official-partner) - -**WARNING!** The [Edgegap plugin published on Unity Asset Store](https://assetstore.unity.com/packages/tools/network/edgegap-game-server-hosting-212563) is outdated and not supported anymore. If you've previously installed our plugin by another method than described above, please remove any Edgegap files or dependencies related before updating your plugin using the git URL. +- [Unity Asset Store package](https://assetstore.unity.com/packages/tools/network/edgegap-game-server-hosting-212563) +- [Mirror Networking source](https://github.com/MirrorNetworking/Mirror) +- [Mirror Networking free package](https://assetstore.unity.com/packages/tools/network/mirror-129321) +- [Mirror Networking LTS package](https://assetstore.unity.com/packages/tools/network/mirror-lts-102631) +- [Fish Networking source](https://github.com/FirstGearGames/FishNet) +- [Fish Networking free package](https://assetstore.unity.com/packages/tools/network/fishnet-networking-evolved-207815) +- [Fish Networking Pro package](https://assetstore.unity.com/packages/tools/network/fishnet-pro-networking-evolved-287711) ## Next Steps Once you have it, check for **Tools** -> **Edgegap Hosting** in Unity's top menu. +### Usage requirements + +To take full advantage of our Unity plugin's build features, you will need to: +- [Create an Edgegap Free Tier account](https://app.edgegap.com/auth/register), +- [Install Docker Desktop](https://www.docker.com/products/docker-desktop/) (or Docker CLI), +- Install Unity Linux Build Support modules for Unity. + From here, we recommend following our [Unity Plugin Guide](https://docs.edgegap.com/docs/tools-and-integrations/unity-plugin-guide) to get your first dedicated server deployed. ### Update the Plugin in Unity diff --git a/Assets/Mirror/Hosting/Edgegap/package.json b/Assets/Mirror/Hosting/Edgegap/package.json index baf5e4bc4..2863cc656 100644 --- a/Assets/Mirror/Hosting/Edgegap/package.json +++ b/Assets/Mirror/Hosting/Edgegap/package.json @@ -1,6 +1,6 @@ { "name": "com.edgegap.unity-servers-plugin", - "version": "1.0.8", + "version": "2.3.1", "displayName": "Edgegap Servers Quickstart", "description": "Get started quickly with Edgegap Dedicated Server hosting.", "unity": "2021.3", @@ -18,4 +18,4 @@ "email": "contact@edgegap.com", "url": "https://www.edgegap.com" } -} +} \ No newline at end of file