Exemple #1
0
        public static void Save <T>(T _data, string password)
        {
            var m_data = JsonUtility.ToJson(_data);

            m_data = DataEncoder.EncryptThis(m_data, password);
            File.WriteAllBytes(filePath, Encoding.UTF8.GetBytes(m_data));
        }
Exemple #2
0
        public static T Load <T>(T defaultData, string password)
        {
            if (!File.Exists(filePath))
            {
                Save(defaultData, password);
                return(Load(defaultData, password));
            }
            var m_data     = File.ReadAllBytes(filePath);
            var dataAsText = Encoding.UTF8.GetString(m_data);

            dataAsText = DataEncoder.Decrypt(dataAsText, password);
            Debug.Log(dataAsText);
            return(JsonUtility.FromJson <T>(dataAsText));
        }