add加密文件
This commit is contained in:
parent
5382863b0b
commit
f3db37ae71
76
xiaofang/Assets/comm/ProtoBuffer.cs
Normal file
76
xiaofang/Assets/comm/ProtoBuffer.cs
Normal file
@ -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;
|
||||
}
|
||||
}
|
11
xiaofang/Assets/comm/ProtoBuffer.cs.meta
Normal file
11
xiaofang/Assets/comm/ProtoBuffer.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbc3058e995ec9d41927fef54df44a13
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user