예제 #1
0
        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);
        }
예제 #2
0
		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;
		}
예제 #3
0
		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;
		}
예제 #4
0
		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;
		}
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
		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;
		}
예제 #9
0
        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);
        }
예제 #10
0
		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;
		}