APITest.cs
using System.Collections; using UnityEngine; using UnityEngine.Networking; using SimpleJSON; using System; public class APITest : MonoBehaviour { private const string BaseUrl = "https://api.gamification.oshimodev.xyz/api/"; private string token; private string username; private string password; [SerializeField] private AudioClip[] audioClips; private IEnumerator Start() { yield return StartCoroutine(InitializeUser()); yield return StartCoroutine(SilentLogin()); yield return StartCoroutine(GetUserOshiStatus()); } private IEnumerator InitializeUser() { using (UnityWebRequest www = UnityWebRequest.Post(BaseUrl + "users/initialize", "")) { yield return www.SendWebRequest(); HandleResponse(www, jsonResponse => { username = jsonResponse["username"]; password = jsonResponse["password"];