Exemplo n.º 1
0
 public static void Save(string path, Action <BinaryWriter> onWriter)
 {
     using (FileStream fs = new FileStream(GetFullPath(path), FileMode.Create, FileAccess.Write))
         using (BinaryWriter bw = new BinaryWriter(fs))
         {
             SystemUtility.SafeCall(onWriter, bw);
         }
 }
Exemplo n.º 2
0
 public static void Load(string path, Action <BinaryReader> onReader)
 {
     using (FileStream fs = new FileStream(GetFullPath(path), FileMode.Open, FileAccess.Read))
         using (BinaryReader br = new BinaryReader(fs))
         {
             SystemUtility.SafeCall(onReader, br);
         }
 }
        public static IEnumerator LoadStreamingAssets(string path, Action <byte[]> result)
        {
            string fullPath = Path.Combine(Application.streamingAssetsPath + path);

            #if UNITY_ANDROID && !UNITY_EDITOR
            using (var www = new WWW(fullPath))
            {
                yield return(www);

                if (string.IsNullOrEmpty(www.error))
                {
                    throw new Exception(www.error);
                }

                SystemUtility.SafeCall(result, www.bytes);
            }
            #else
            SystemUtility.SafeCall(result, File.ReadAllBytes(fullPath));
            yield break;
            #endif
        }