Exemple #1
0
        /// <summary>
        /// Loads the text.
        /// 注意路径都在Asset目录下,不包含Asset目录
        /// </summary>
        public static string LoadTxt(FileLoc loc, string appLang, string pathToMod)
        {
            string uriPath = GetUriPath(loc.uri, appLang, loc.modPath);

            if (loc.uri == FileUri.PATCH_DIR || loc.uri == FileUri.PATCH_LANG_DIR)
            {
                return(RawLoadText(Path.Combine(uriPath, pathToMod)));
            }
            else if (loc.uri == FileUri.RES_DIR || (loc.uri == FileUri.RES_LANG_DIR))
            {
#if UNITY_EDITOR || SGAF_SERVER || SGAF_ROBOT
                return(RawLoadText(Path.Combine(uriPath, pathToMod)));
#elif UNITY_ANDROID || UNITY_IOS
                string    relativeToRes = GetPathWithoutExt(Path.Combine(uriPath, pathToMod));
                TextAsset ts            = Resources.Load(relativeToRes) as TextAsset;
                if (ts == null)
                {
                    Logger.Error("LoadTxt in res failed: {0}    rel:{1}", pathToMod, relativeToRes);
                    return(null);
                }
                return(ts.text);
#endif
            }
            else if (loc.uri == FileUri.STREAM_DIR || loc.uri == FileUri.STREAM_LANG_DIR)
            {
#if UNITY_EDITOR || SGAF_SERVER || UNITY_IOS
                return(RawLoadText(Path.Combine(uriPath, pathToMod)));
#elif UNITY_ANDROID
                // todo: call android method
                return(null);
#endif
            }
            else
            {
                Logger.Error("Unknown FileUri: " + loc.uri);
                return(null);
            }
        }
Exemple #2
0
        /// <summary>
        /// Write the text.
        /// </summary>
        /// <param name="loc"></param>
        /// <param name="appLang"></param>
        /// <param name="pathToMod"></param>
        /// <param name="contents"></param>
        public static void WriteTxt(FileLoc loc, string appLang, string pathToMod, string contents)
        {
            string uriPath = GetUriPath(loc.uri, appLang, loc.modPath);

            RawWriteText(Path.Combine(uriPath, pathToMod), contents);
        }