public static string ReadTextFileFromResources(string path, ZipDelegate zip = null) { string result = null; if (Application.isPlaying) { string ext = Path.GetExtension(path); NSUtils.Assert(string.IsNullOrEmpty(ext) || ext == ".txt" || ext == ".json", "FileUtils: Text file in Resources folder must be '*.txt', '*.json' or none extends format!"); if (!string.IsNullOrEmpty(ext)) { path = path.Replace(ext, ""); } TextAsset txt = Resources.Load <TextAsset> (path); NSUtils.Assert(txt != null, "No file found at {0}", path); result = txt.text; } else if (File.Exists(path)) { // result = System.IO.File.ReadAllText(path); result = ReadStringFromPath(path); } if (zip != null) { result = zip.unZip(result); } return(result); }
public static string ReadTextFileFromURL(string url, ZipDelegate zip=null){ WWW www = new WWW(url); while(!www.isDone){} string text = www.text; if (zip != null) text = zip.unZip (text); return text; }
public static string ReadTextFileFromExternal(string path, ZipDelegate zip=null){ string result = null; if (File.Exists (path)) { result = ReadStringFromPath(path); } if (zip != null) result = zip.unZip (result); return result; }
public static string ReadTextFileFromStreamAssets(string path, ZipDelegate zip=null){ string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, path); string result = null; if (filePath.Contains("://")) { result = ReadTextFileFromURL(filePath, zip); } else{ result = ReadStringFromPath(path); if (zip != null) result = zip.unZip (result); } return result; }
public static string ReadTextFileFromExternal(string path, ZipDelegate zip = null) { string result = PlayerPrefs.GetString(path); if (result != null && result.Trim().Length == 0) { result = null; } if (zip != null) { result = zip.unZip(result); } return(result); }
public static string ReadTextFileFromExternal(string path, ZipDelegate zip = null) { string result = null; if (File.Exists(path)) { result = ReadStringFromPath(path); } if (zip != null) { result = zip.unZip(result); } return(result); }
public static string ReadTextFileFromURL(string url, ZipDelegate zip = null) { WWW www = new WWW(url); while (!www.isDone) { } string text = www.text; if (zip != null) { text = zip.unZip(text); } return(text); }
public static string ReadTextFileFromResources(string path, ZipDelegate zip=null){ string result = null; if (Application.isPlaying) { NSUtils.Assert (path.EndsWith (".txt"), "FileUtils: Text file in Resources folder must be '*.txt' format!"); string ext = Path.GetExtension(path); path = path.Replace (ext, ""); TextAsset txt = Resources.Load<TextAsset> (path); NSUtils.Assert (txt!=null, "No file found at {0}", path); result = txt.text; }else if (File.Exists (path)) { // result = System.IO.File.ReadAllText(path); result = ReadStringFromPath(path); } if (zip != null) result = zip.unZip (result); return result; }
public static string ReadTextFileFromStreamAssets(string path, ZipDelegate zip = null) { string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, path); string result = null; if (filePath.Contains("://")) { result = ReadTextFileFromURL(filePath, zip); } else { result = ReadStringFromPath(filePath); if (zip != null) { result = zip.unZip(result); } } return(result); }
public static string ReadTextFileFromExternal(string path, ZipDelegate zip=null){ string result = PlayerPrefs.GetString (path); if(result!=null && result.Trim().Length==0){ result = null; } if (zip != null) result = zip.unZip (result); return result; }