_TheStrongestSnail/TheStrongestSnail/Assets/TextMesh Pro/UI/UI.cs
2024-12-09 20:24:01 +08:00

77 lines
1.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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