private void SaveWebhooks() { if (webhooks.ContainsKey(Application.productName)) { webhooks [Application.productName] = webhookURL; } else { webhooks.Add(Application.productName, webhookURL); } if (File.Exists(System.Environment.GetEnvironmentVariable("HOME") + "/webhooks.txt") && webhooks != null) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(System.Environment.GetEnvironmentVariable("HOME") + "/webhooks.txt", FileMode.Open); webhookURLs tempHook = new webhookURLs(); tempHook.hooks = webhooks; bf.Serialize(file, tempHook); file.Close(); } else { UnityEngine.Debug.LogError("Webhooks text file not found!"); } instance._webhookURL = webhookURL; }
private void LoadWebhooks() { if (File.Exists(System.Environment.GetEnvironmentVariable("HOME") + "/webhooks.txt")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(System.Environment.GetEnvironmentVariable("HOME") + "/webhooks.txt", FileMode.Open); webhookURLs loadedHooks = (webhookURLs)bf.Deserialize(file); file.Close(); webhooks = loadedHooks.hooks; } else { UnityEngine.Debug.LogError("Webhooks not found!"); UnityEngine.Debug.Log("Creating webhooks..."); CreateWebhooks(); } string value; if (webhooks.ContainsKey(Application.productName)) { webhookURL = webhooks [Application.productName]; } else { UnityEngine.Debug.Log("No webhook for this URL"); webhooks.Add(Application.productName, webhookURL); SaveWebhooks(); } Debug.Log(webhookURL); }