public IABManifestLoader() { assetManifeset = null; manifesetLoader = null; loadState = 0; manifestPath = null; //file:///E:/BaiduYunDownload/Assets/Assets/StreamingAssets/AssetBundles/Windows/Windows manifestPath = IPathTools.GetAssetBundleFilePath(IPathTools.GetRuntimeFolder()); if (!IFileTools.IsExistFile(manifestPath)) { isUsingWWW = true; manifestPath = IPathTools.GetAssetBundleWWWStreamPath(IPathTools.GetRuntimeFolder()); } Debuger.Log("manifestPath ===" + manifestPath); Debuger.Log("manifestPath 222===" + isUsingWWW.ToString()); // manifestPath = "C:/Users/yujie/AppData/LocalLow/JFYD/Fish/AssetBundles/Android/Android"; // manifestPath = Application.persistentDataPath + "/AssetBundles/Android/Android"; // Debug.Log("manifestPath =111=" + manifestPath); }
public static string GetAssetBundleWWWStreamPath(string path) { string tmpPath = IPathTools.kAssetBundlesOutputPath + "/" + IPathTools.GetRuntimeFolder() + "/" + path; tmpPath = GetWWWStreamPath() + tmpPath; return(tmpPath); }
/// <summary> /// 第一步读取 整个场景的配置文件 /// </summary> /// <param name="path"></param> public void ReadConfiger(string fileName) { string path = IPathTools.GetAssetBundleFilePath(fileName); ReadConfig(path); }
//public static void DeleteFolder(string dir) //{ // foreach (string d in Directory.GetFileSystemEntries(dir)) // { // if (File.Exists(d)) // { // FileInfo fi = new FileInfo(d); // if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1) // fi.Attributes = FileAttributes.Normal; // File.Delete(d);//直接删除其中的文件 // } // else // DeleteFolder(d);//递归删除子文件夹 // } // Directory.Delete(dir);//删除已空文件夹 //} //private void DeleteDir(string path) //{ // if (path.Trim() == "" || !Directory.Exists(path)) // return; // DirectoryInfo dirInfo = new DirectoryInfo(path); // FileInfo[] fileInfos = dirInfo.GetFiles(); // if (fileInfos != null && fileInfos.Length > 0) // { // foreach (FileInfo fileInfo in fileInfos) // { // //DateTime.Compare( fileInfo.LastWriteTime,DateTime.Now); // File.Delete(fileInfo.FullName); //删除文件 // } // } // DirectoryInfo[] dirInfos = dirInfo.GetDirectories(); // if (dirInfos != null && dirInfos.Length > 0) // { // foreach (DirectoryInfo childDirInfo in dirInfos) // { // this.DeleteDir(childDirInfo.FullName); //递归 // } // } // Directory.Delete(dirInfo.FullName, true); //删除目录 //} public static void DeleteFolder(string strfrompath) { //如果源文件夹不存在,则创建 if (!Directory.Exists(strfrompath)) { return; } DirectoryInfo dir = new DirectoryInfo(strfrompath); FileSystemInfo[] filesinfo = dir.GetFileSystemInfos(); for (int i = 0; i < filesinfo.Length; i++) { FileSystemInfo tmpfile = filesinfo[i]; if (tmpfile is FileInfo) { File.Delete(tmpfile.FullName); } else if (tmpfile is DirectoryInfo) { string tmpsoure = strfrompath + "\\" + tmpfile.Name; tmpsoure = IPathTools.FixedPath(tmpsoure); DeleteFolder(tmpsoure); } } // Debug.Log(filesinfo.Length); if (filesinfo.Length <= 0) { dir = null; // Debug.Log(strfrompath + "== is deleting"); // FileUtil.DeleteFileOrDirectory(strfrompath); //Directory.Delete(); //dir.Delete(true); Directory.Delete(strfrompath, true); } }
/// <summary> /// art/scences/ /// </summary> AssetBundle.LoadFromFile /// <param name="path"> </param> /// <returns></returns> public static string GetAssetBundleFilePath(string path) { string tmpPath = "/" + IPathTools.kAssetBundlesOutputPath + "/" + IPathTools.GetRuntimeFolder() + "/" + path; if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.OSXEditor) { tmpPath = GetAssetStreamPath() + tmpPath; } else { tmpPath = GetAssetPersistentPath() + tmpPath; } // tmpPath = ITools.FixedPath(tmpPath); return(tmpPath); }
public static void CopyFolder(string strFromPath, string strToPath) { //如果源文件夹不存在,则创建 if (!Directory.Exists(strFromPath)) { Directory.CreateDirectory(strFromPath); } //如果目标文件夹中没有源文件夹则在目标文件夹中创建源文件夹 if (!Directory.Exists(strToPath)) { Directory.CreateDirectory(strToPath); } DirectoryInfo dir = new DirectoryInfo(strFromPath); FileSystemInfo[] filesInfo = dir.GetFileSystemInfos(); for (int i = 0; i < filesInfo.Length; i++) { FileSystemInfo tmpFile = filesInfo[i]; string tmpSoure = strFromPath + "\\" + tmpFile.Name; tmpSoure = IPathTools.FixedPath(tmpSoure); string tmpDist = strToPath + "\\" + tmpFile.Name; tmpDist = IPathTools.FixedPath(tmpDist); if (tmpFile is FileInfo) { File.Copy(tmpSoure, tmpDist, true); } else if (tmpFile is DirectoryInfo) { CopyFolder(tmpSoure, tmpDist); } } }
/// <summary> /// 加载公共资源 /// </summary> /// <summary> /// 开始载入,在Unity3d环境中用StartCoroutine()来开始一个资源的载入 /// /// commonResourcesPath ==file:///E:/SVN/3DFish/Project/Fish/Assets/StreamingAssets/AssetBundles/Windows/scenceone/prefeb.ld /// </summary> /// <returns></returns> public IEnumerator CommonLoad() { commonResourcesDone = 0; string bundlePath = IPathTools.GetAssetBundleFilePath(bundleName); // Debuger.Log("bundlePath =="+ bundlePath); //判断persistent是否存在 if (!IFileTools.IsExistFile(bundlePath)) { bundlePath = IPathTools.GetAssetBundleWWWStreamPath(bundleName); WWW bundle = WWW.LoadFromCacheOrDownload(bundlePath, FrameTools.VersionId); yield return(bundle); if (!string.IsNullOrEmpty(bundle.error)) { Debuger.Log(bundle.error); // yield break; } else { // Debug.Log("manifestPath =777777=" + bundle.progress); commonResourcesDone = 1.0f; commonRes = new ResIndexers(bundle.assetBundle); // Debug.Log("commonResourcesPath load finish= 2222=" + tmpRequest.assetBundle); this.loadFinish(bundleName); loadPorgress(bundleName, commonResourcesDone); } } else { AssetBundleCreateRequest tmpRequest = AssetBundle.LoadFromFileAsync(bundlePath); yield return(tmpRequest); if (tmpRequest.assetBundle != null) { commonResourcesDone = 1.0f; // Debug.Log("commonResourcesPath load finish= 2222=" + bundleName); commonRes = new ResIndexers(tmpRequest.assetBundle); // Debug.Log("commonResourcesPath load finish= 2222=" + tmpRequest.assetBundle); this.loadFinish(bundleName); loadPorgress(bundleName, commonResourcesDone); } else { Debuger.LogError(" bundleName is not finish ==" + bundleName); // yield break; } } }