Esempio n. 1
0
        //得到下载下来用于WWW加载时针对平台所用的路径,CS版本
        public static string getDownLoadPathForPlatform_CS()
        {
#if UNITY_EDITOR_WIN
            return(_editordownloadpath + getPlatformString());
#else
            return(RG_Utils.getDownloadPath() + "/" + getPlatformString());
#endif
        }
Esempio n. 2
0
        //得到当前平台下载下来的存放bundle文件的路径,用于WWW加载
        public static string getDownloadPathURL()
        {
            string PathURL =
#if UNITY_EDITOR
#if UNITY_EDITOR_WIN
                "file://" + _editordownloadpath;
#else
                "file://" + RG_Utils.getDownloadPath() + "/";
#endif
#elif UNITY_ANDROID
                "file://" + RG_Utils.getDownloadPath() + "/";
#elif UNITY_IPHONE
                "file://" + RG_Utils.getDownloadPath() + "/";
#elif UNITY_STANDALONE_WIN || UNITY_EDITOR || UNITY_WEBPLAYER || UNITY_WP8
                "file://" + RG_Utils.getDownloadPath() + "/";
#else
                string.Empty;
#endif
            return(PathURL);
        }
Esempio n. 3
0
        /// <summary>
        /// 存储二进制文件到Application.persistentDataPath目录,因权限问题,在PC上会放到d:/androidtest
        /// </summary>
        /// <param name="fileName">文件名</param>
        /// <param name="bytes">二进制内容</param>
        /// <returns></returns>
        static public bool Save(string fileName, byte[] bytes)
        {
#if UNITY_WEBPLAYER || UNITY_FLASH || UNITY_METRO || UNITY_WP8 || UNITY_WP_8_1
            return(false);
#else
#if UNITY_EDITOR_WIN
            string path = _editordownloadpath + fileName;
#else
            string path = RG_Utils.getDownloadPath() + "/" + fileName;
#endif



            if (bytes == null)
            {
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
                return(true);
            }

            FileStream file = null;

            try
            {
                file = File.Create(path);
            }
            catch (System.Exception ex)
            {
                Debug.LogError(ex.Message);
                return(false);
            }

            file.Write(bytes, 0, bytes.Length);
            file.Close();
            return(true);
#endif
        }