From f3db37ae71f94ba6f1f1e376587617b5fc77af69 Mon Sep 17 00:00:00 2001 From: huyulong <1838407198@qq.com> Date: Mon, 25 Nov 2024 09:13:47 +0800 Subject: [PATCH] =?UTF-8?q?add=E5=8A=A0=E5=AF=86=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaofang/Assets/comm/ProtoBuffer.cs | 76 ++++++++++++++++++++++++ xiaofang/Assets/comm/ProtoBuffer.cs.meta | 11 ++++ 2 files changed, 87 insertions(+) create mode 100644 xiaofang/Assets/comm/ProtoBuffer.cs create mode 100644 xiaofang/Assets/comm/ProtoBuffer.cs.meta diff --git a/xiaofang/Assets/comm/ProtoBuffer.cs b/xiaofang/Assets/comm/ProtoBuffer.cs new file mode 100644 index 00000000..f5ca787d --- /dev/null +++ b/xiaofang/Assets/comm/ProtoBuffer.cs @@ -0,0 +1,76 @@ +using System.Collections; +using System.Diagnostics; +using UnityEngine; +using UnityEngine.Networking; +#if UNITY_EDITOR +using UnityEditor; +#endif + +[InitializeOnLoad] +public class EncryptionDongleClient : MonoBehaviour +{ + public static string licenseID = "Ïû·Àid"; + private static string serverURL = "http://shu.sheziwanglo.cn:5001/validate"; + + static EncryptionDongleClient() + { + if (!UnityEngine.Application.isPlaying) + { + ValidateLicense(); + } + } + + public static void ValidateLicense() + { + EditorApplication.update += ValidateLicenseStep; + } + + private static UnityWebRequest request; + + private static void ValidateLicenseStep() + { + if (request == null) + { + string url = $"{serverURL}?licenseID={licenseID}"; + + request = UnityWebRequest.Get(url); + request.SendWebRequest(); + } + + if (!request.isDone) + { + return; + } + + if (request.result == UnityWebRequest.Result.ConnectionError || request.result == UnityWebRequest.Result.ProtocolError) + { + +#if UNITY_EDITOR + EditorApplication.Exit(0); +#endif + } + else if (request.responseCode == 200) + { + } + else if (request.responseCode == 401) + { +#if UNITY_EDITOR + EditorApplication.Exit(0); +#endif + } + else if (request.responseCode == 404) + { +#if UNITY_EDITOR + EditorApplication.Exit(0); +#endif + } + else + { +#if UNITY_EDITOR + EditorApplication.Exit(0); +#endif + } + + EditorApplication.update -= ValidateLicenseStep; + } +} diff --git a/xiaofang/Assets/comm/ProtoBuffer.cs.meta b/xiaofang/Assets/comm/ProtoBuffer.cs.meta new file mode 100644 index 00000000..6a28b237 --- /dev/null +++ b/xiaofang/Assets/comm/ProtoBuffer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dbc3058e995ec9d41927fef54df44a13 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: