BBGamelib.FileUtils.ReadTextFileFromResources C# (CSharp) Method

ReadTextFileFromResources() public static method

public static ReadTextFileFromResources ( string path, ZipDelegate zip = null ) : string
path string
zip ZipDelegate
return string
		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;
		}
		

Usage Example

Beispiel #1
0
        public static NSDictionary DictionaryWithContentsOfFileFromResources(string path, FileUtils.ZipDelegate zip = null)
        {
            string text = FileUtils.ReadTextFileFromResources(path);

            if (zip != null)
            {
                text = zip.unZip(text);
            }
            NSDictionary dict = DictionaryWithContentsOfString(text, zip);

            return(dict);
        }
All Usage Examples Of BBGamelib.FileUtils::ReadTextFileFromResources