OldBlueWater/BlueWater/Assets/02.Scripts/Utility/Upd.cs
IDMhan 451b97ace1 Closes #158 Change Player Visual
Spum Rabbit Character
2024-01-25 03:38:38 +09:00

88 lines
2.7 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Networking;
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
[System.Serializable]
public class GoogleData
{
public string order, result, msg;
}
public class Upd : MonoBehaviour
{
const string URL = "https://script.google.com/macros/s/AKfycbxRZe-YsV-Yy43VI-fsLxXZ7qLXkf9Dw-RBzPUH3JDH-ZeucGHQx6kX-to-mnbYBkEizA/exec";
private GoogleData GD;
TimeSpan startTime;
private void Start()
{
startTime = System.DateTime.Now.TimeOfDay;
}
public void Register()
{
var deviceUniqueIdentifier = SystemInfo.deviceUniqueIdentifier; // 기기 고유 식별자
var date = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); // 현재 날짜
var processorType = SystemInfo.processorType; // CPU
var graphicsDeviceName = SystemInfo.graphicsDeviceName; // GPU
var systemMemorySize = (SystemInfo.systemMemorySize / 1024).ToString() + "GB"; // 시스템 메모리 크기
var playTime = System.DateTime.Now.TimeOfDay - startTime;
var form = new WWWForm();
form.AddField("order", "register");
form.AddField("id", deviceUniqueIdentifier);
form.AddField("date", date);
form.AddField("cpu", processorType);
form.AddField("gpu", graphicsDeviceName);
form.AddField("memory", systemMemorySize);
form.AddField("playtime", playTime.ToString());
StartCoroutine(Post(form));
}
IEnumerator Post(WWWForm form)
{
using UnityWebRequest www = UnityWebRequest.Post(URL, form);
yield return www.SendWebRequest();
if (www.isDone) Response(www.downloadHandler.text);
else print("웹의 응답이 없습니다.");
}
void Response(string json)
{
if (string.IsNullOrEmpty(json)) return;
GD = JsonUtility.FromJson<GoogleData>(json);
if (GD.result == "ERROR")
{
print(GD.order + "을 실행할 수 없습니다. 에러 메시지 : " + GD.msg);
return;
}
//print(GD.order + "을 실행했습니다. 메시지 : " + GD.msg);
}
void RemoveCache()
{
var form = new WWWForm();
form.AddField("order", "removeCache");
StartCoroutine(Post(form));
}
private void OnApplicationQuit()
{
Register();
}
}
}