public static string ReadTextUserData(string filename) { #if UNITY_XBOXONE && !UNITY_EDITOR byte [] bytes = XboxOneConnectedStorage.GetData(filename); if (bytes == null) { return(null); } else { return(new string(Encoding.ASCII.GetChars(bytes))); } #elif UNITY_PS4 && !UNITY_EDITOR byte [] bytes = PS4Manager.ReadData(filename); if (bytes == null) { return(null); } else { return(new string(Encoding.ASCII.GetChars(bytes))); } #else try { return(File.ReadAllText(Path.Combine(persistentDataPath, filename))); } catch { return(null); } #endif }
//Read a chunk of data from the per-user storage public static byte[] ReadBinaryUserData(string filename) { #if UNITY_XBOXONE && !UNITY_EDITOR return(XboxOneConnectedStorage.GetData(filename)); #elif UNITY_PS4 && !UNITY_EDITOR return(PS4Manager.ReadData(filename)); #else try { return(File.ReadAllBytes(Path.Combine(persistentDataPath, filename))); } catch { return(null); } #endif }