private void OnEnable() { if (File.Exists(path)) { StreamReader reader = new StreamReader(path); string jsonData = reader.ReadToEnd(); ColorPresets = JsonUtility.FromJson <ColorPresetsClass>(jsonData); reader.Close(); } }
void Start() { path = Application.persistentDataPath + "/ColorPresets/presets.json"; if (File.Exists(path)) { StreamReader reader = new StreamReader(path); string jsonData = reader.ReadToEnd(); ColorPresets = JsonUtility.FromJson <ColorPresetsClass>(jsonData); reader.Close(); } else { FileInfo file1 = new System.IO.FileInfo(Application.persistentDataPath + "/ColorPresets/"); file1.Directory.Create(); string jsonData = JsonUtility.ToJson(ColorPresets.presets, true); File.WriteAllText(path, jsonData); } RValue.SetValue(OutColor.r); GValue.SetValue(OutColor.g); BValue.SetValue(OutColor.b); Color.RGBToHSV(OutColor, out float H, out float S, out float V); HValue.SetValue(H); SValue.SetValue(S); VValue.SetValue(V); HexValue.SetValue(ColorUtility.ToHtmlStringRGB(OutColor)); UpdateColorRGB(); }