public void ReadConfiger(string filePath) { string textFileName = "Record.txt"; string path = IPathTools.GetAssetBundlePath() + "/" + filePath + textFileName; ReadConfig(path); }
//循环加载依赖项 public IEnumerator LoadDependencesAssetBundle(string path) { while (!isLoadManifestFinished) { yield return(null); } using (WWW www = new WWW(path)) { yield return(www); if (!string.IsNullOrEmpty(www.error)) { Debug.Log(www.error); } else { if (www.progress >= 1.0) { AssetBundle ab = www.assetBundle; if (!abDic.ContainsKey(ab.name)) { abDic.Add(ab.name, ab); Debug.Log("依赖ab.name = " + ab.name); } string[] dependences = assetManifest.GetAllDependencies(ab.name); for (int i = 0, iMax = dependences.Length; i < iMax; ++i) { string abPath = IPathTools.GetAssetBundlePath() + "/" + dependences[i]; yield return(LoadDependencesAssetBundle(abPath)); } } } } }
public IABManifestLoader() { assetBundleManifest = null; manifestloader = null; isFinishedLoad = false; assetManifestName = IPathTools.GetABMainfestName(); }
public IABManifestLoader() { assetManifest = null; manifestLoader = null; isLoadFinish = false; manifestPath = IPathTools.GetWWWAssetBundlePath() + "/" + IPathTools.GetPlatFormFolderName(Application.platform); }
public static void ClearAssetBundle() { string outputPath = Path.Combine(Path.Combine(System.Environment.CurrentDirectory, IPathTools.kAssetBundlesOutputPath), GetPlatformFolderForAssetBundles(EditorUserBuildSettings.activeBuildTarget)); outputPath = IPathTools.FixedPath(outputPath); Debug.Log(outputPath); if (Directory.Exists(outputPath)) { FileUtil.DeleteFileOrDirectory(outputPath); // Directory.Delete(outputPath, true); } outputPath = Path.Combine(Application.streamingAssetsPath, IPathTools.kAssetBundlesOutputPath); outputPath = Path.Combine(outputPath, GetPlatformFolderForAssetBundles(EditorUserBuildSettings.activeBuildTarget)); outputPath = IPathTools.FixedPath(outputPath); Debug.Log(outputPath); if (Directory.Exists(outputPath)) { FileUtil.DeleteFileOrDirectory(outputPath); // ITools.DeleteFolder(outputPath); } AssetDatabase.Refresh(); }
static void CopyAssetBundlesTo(string outputPath) { FileUtil.DeleteFileOrDirectory(Application.streamingAssetsPath); outputPath = IPathTools.FixedPath(outputPath); Directory.CreateDirectory(outputPath); string outputFolder = GetPlatformFolderForAssetBundles(EditorUserBuildSettings.activeBuildTarget); // Setup the source folder for assetbundles. var source = Path.Combine(Path.Combine(System.Environment.CurrentDirectory, IPathTools.kAssetBundlesOutputPath), outputFolder); if (!System.IO.Directory.Exists(source)) { Debug.Log("No assetBundle output folder, try to build the assetBundles first."); } // Setup the destination folder for assetbundles. var destination = System.IO.Path.Combine(outputPath, outputFolder); destination = IPathTools.FixedPath(destination); if (System.IO.Directory.Exists(destination)) { // Directory.CreateDirectory(destination); FileUtil.DeleteFileOrDirectory(destination); } Directory.Move(source, destination); // FileUtil.CopyFileOrDirectory(source, destination); // // Clear streaming assets folder. //FileUtil.DeleteFileOrDirectory(Application.streamingAssetsPath); // outputPath = ITools.FixedPath(outputPath); // Directory.CreateDirectory(outputPath); // string outputFolder = GetPlatformFolderForAssetBundles(EditorUserBuildSettings.activeBuildTarget); // // Setup the source folder for assetbundles. // var source = Path.Combine(Path.Combine(System.Environment.CurrentDirectory, ITools.kAssetBundlesOutputPath), outputFolder); // if (!System.IO.Directory.Exists(source)) // Debug.Log("No assetBundle output folder, try to build the assetBundles first."); // // Setup the destination folder for assetbundles. // var destination = System.IO.Path.Combine(outputPath, outputFolder); // if (System.IO.Directory.Exists(destination)) // FileUtil.DeleteFileOrDirectory(destination); // FileUtil.CopyFileOrDirectory(source, destination); }
/// <summary> /// 场景名字 SceneOne /// </summary> /// <param name="fileName"></param> public void ReadConfiger(string scenename) { string path = IPathTools.GetAssetBundlePath() + "/" + scenename + "Record.txt"; allAsset = new Dictionary <string, string>(); abManager = new IABManager(scenename); ReadConfig(path); }
/// <summary> /// 通过场景名读取配置文件 /// </summary> /// <param name="fileName">场景名字</param> public void ReadConfigByName(string sceneName) { string textFileName = "Record.txt"; string path = IPathTools.GetAssetBundlePath() + "/" + sceneName + textFileName; mABManager = new IABManager(sceneName); ReadConfigByPath(path); }
string GetBundlePath(string bundleName) { string path = Path.Combine(IPathTools.GetAssetBundlePath(), bundleName); path = IPathTools.StandardPath(path); Debug.Log(path); return(path); }
public static void BuildAssetBundle() { //streamingassetpath string outPath = IPathTools.GetAssetBundlePath(); //Application.streamingAssetsPath + "/AssetBundle"; BuildPipeline.BuildAssetBundles(outPath, 0, EditorUserBuildSettings.activeBuildTarget); AssetDatabase.Refresh(); }
private IABManifestLoader() { ABManifest = null; ManifestLoader = null; mIsLoadFinish = false; //ManifestPath = IPathTools.GetWWWAssetBundlePath() + "/" + IPathTools.GetPlatformFolderName(Application.platform); ManifestPath = IPathTools.GetAssetBundlePath() + "/" + IPathTools.GetPlatformFolderName(Application.platform); }
// Use this for initialization void Start() { manifestPath = IPathTools.GetABMainfestName(); StartCoroutine(LoadManifest()); string path = IPathTools.GetAssetBundlePath() + "/load.ab"; StartCoroutine(LoadAssetBundle(path)); }
public void Initial(string bundleName, LoaderProgrecess progress) { IsLoadFinish = false; theBundleName = bundleName; loaderProgrecess = progress; assetLoader = new IABLoader(IPathTools.GetWWWAssetBundlePath() + "/" + theBundleName, IPathTools.GetAssetBundlePath() + "/" + theBundleName, theBundleName, progress, BundleLoadFinish); }
public IABManifestLoader() { assetManifest = null; manifestLoader = null; IsLoadFinish = false; manifestPath = IPathTools.GetABPath(); }
public void Initial(string bundle, LoaderProgress progress) { bundleName = bundle; IsLoadFinish = false; loaderProcess = progress; assetLoader = new IABLoader(progress, BundleLoadFinish); assetLoader.SetBundleName(bundle); string bundlePath = IPathTools.GetWWWAssetBundlePath() + "/" + bundle; assetLoader.LoadResources(bundlePath); }
public IABManifestLoader() { manifestBundle = null; assetManifest = null; isLoadFish = false; //fixed //file:///c:/user/lenovo/Desktop/Game/Assets/StreamingAssets/Windows/Windows(是windows的manifest文件) ManifestPath = IPathTools.GetWWWAssetBundlePath() + "/" + IPathTools.GetPlatformFolderName(Application.platform); }
public void Initial(string bundlePath, LoaderProgress progress) { mIsLoadFinish = false; mbundlePath = bundlePath; mLoaderProgress = progress; mABLoader = new IABLoader(progress, BundleLoadFinish); mABLoader.SetBundleName(bundlePath); string fullPathWWW = IPathTools.GetWWWAssetBundlePath() + "/" + bundlePath; string fullPathFile = IPathTools.GetAssetBundlePath() + "/" + bundlePath; mABLoader.LoadResources(fullPathWWW, fullPathFile); }
public IABManifestLoader() { assetManifeset = null; manifesetLoader = null; isLoadFinish = false; //fixed // file:///C:/Users/lenovo/Desktop/zyj/Game/TeacherManniu/Assets/StreamingAssets/Windows/Windows manifesetPath = IPathTools.GetAssetBundleWWWStreamPath(IPathTools.GetRuntimeFolder()); }
public static void BuildeAssetBundle() { string outPath = IPathTools.GetAssetBundlePath(); if (!Directory.Exists(outPath)) { Directory.CreateDirectory(outPath); } BuildPipeline.BuildAssetBundles(outPath, 0, EditorUserBuildSettings.activeBuildTarget); AssetDatabase.Refresh(); }
public void Initialize(string bundleName, LoadProgress loadProgress) { this.loadProgress = loadProgress; this.bundleName = bundleName; isLoadFinish = false; assetLoader = new IABLoader(loadProgress, OnBundleLoadFinish); // 设置名字和路径 assetLoader.SetBundleName(bundleName); string bundlePath = Path.Combine(IPathTools.GetWWWAssetBundlePath(), bundleName); assetLoader.LoadResources(bundlePath); }
/// <summary> /// /// </summary> /// <returns></returns> public bool CheckIsCopyFile() { if (!File.Exists(IPathTools.GetAssetPersistentPath() + "/" + GloableConfig.LuaFileListName)) { Debuger.Log(" not exist 111 ==="); return(true); } else { // return false; // if (!File.Exists(srcFile)) // { // Debug.Log("srcFile 333 file.txt ==="+srcFile); // return true; // } // // FileStream fs = new FileStream(srcFile, FileMode.Open); // StreamReader sw = new StreamReader(fs); // // string srcArr = sw.ReadLine() ; // // sw.Close(); // // fs.Close(); // // fs = new FileStream(disFile, FileMode.Open); // sw = new StreamReader(fs); // // string disArr = sw.ReadLine(); // // Debuger.Log("srcArr ==="+ srcArr); // Debuger.Log("disArr ===" + disArr); // // sw.Close(); // // fs.Close(); // // // if (disArr != srcArr) // { // return true; // } } return(false); }
//public IEnumerator OnExtractResource() //{ // timeCount = Time.realtimeSinceStartup; // string dataPath = IPathTools.GetAssetPersistentPath() + "/"; //数据目录 // string resPath = IPathTools.GetWWWStreamPath() + "StreamingAssets.zip"; // WWW tmp = new WWW(resPath); // yield return tmp; // MemoryStream memStream = new MemoryStream(tmp.bytes.Length); // FileStream output = new FileStream(dataPath, FileMode.Create); // SevenZip.Compression.LZMA.Encoder coder = new SevenZip.Compression.LZMA.Encoder(); // DataOver(); //} public IEnumerator OnExtractResource() { if (!File.Exists(IPathTools.GetAssetPersistentPath() + "/" + GloableConfig.LuaFileListName)) { willCopyAsset = true; } else { willCopyAsset = false; //yield return LoadText (); } if (willCopyAsset) { timeCount = Time.realtimeSinceStartup; string zipPath = Application.temporaryCachePath + "/tempZip.zip"; string dataPath = IPathTools.GetAssetPersistentPath() + "/"; //数据目录 string resPath = IPathTools.GetWWWStreamPath() + "StreamingAssets.zip"; //游戏包资源目录 Debuger.Log("dataPath ==" + dataPath); Debuger.Log("resPath ==" + resPath); WWW www = new WWW(resPath); yield return(www); var data = www.bytes; File.WriteAllBytes(zipPath, data); try { ZipUtil.Unzip(zipPath, dataPath); } catch (System.Exception e) { Debuger.Log(" e ===" + e); } yield return(null); } Debuger.Log("Finish copy zip =="); DataOver(); }
public void Inital(string bundlename, LoadProgess progess) { isLoadFished = false; theBundleName = bundlename; loadProgess = progess; iABLoader = new IABLoader(progess, BundleLoadFinish); iABLoader.SetBundleName(bundlename); string bundlePath = IPathTools.GetWWWAssetBundlePath() + "/" + bundlename; iABLoader.LoadResources(bundlePath); }
IEnumerator LoadAssetBundle(string path) { while (!isLoadManifestFinished) { yield return(null); } WWW www = new WWW(path); yield return(www); if (!string.IsNullOrEmpty(www.error)) { Debug.Log(www.error); } else { AssetBundle ab = www.assetBundle; //Debug.Log("ab.name = " + ab.name); if (!abDic.ContainsKey(ab.name)) { abDic.Add(ab.name, ab); } string[] dependence = assetManifest.GetAllDependencies(ab.name); for (int i = 0, iMax = dependence.Length; i < iMax; ++i) { Debug.Log(dependence[i]); if (!abDic.ContainsKey(dependence[i])) { string _path = IPathTools.GetAssetBundlePath() + "/" + dependence[i]; yield return(LoadAssetBundle(_path)); } } //实例化 Cube if (ab.name == "load.ab") { AssetBundle bundle = abDic[ab.name]; Object obj = bundle.LoadAsset("Cube"); Instantiate(obj, Vector3.zero, Quaternion.identity); } www.Dispose(); } }
public void ReadConfiger(string scenceName) { // string path=""; // string path = Application.persistentDataPath + "/AssetBundle/" + scenceName + "Record.txt"; string path = IPathTools.GetAssetBundlePath() + "/" + scenceName + "Record.txt"; //Debug.Log("path:"+path ); allAssets = new Dictionary <string, string>(); aBsManager = new IABsManager(scenceName); ReadConfig(path); }
public void Initial(string bundle, LoaderProgrecess progress) { IsLoadFinish = false; theBundleName = bundle; loaderProgress = progress; assetLoader = new IABLoader(progress, BundleLoadFinish); //yujie fixed assetLoader.SetBundleName(bundle); string bundlePath = IPathTools.GetAssetBundleWWWStreamPath(bundle); // IPathTools.GetWWWAssetBundlePath()+"/"+bundle; assetLoader.LoadResources(bundlePath); }
public IEnumerator LoadText() { string srcFile = IPathTools.GetAssetStreamPath() + "/" + GloableConfig.LuaFileListName; string disFile = IPathTools.GetAssetPersistentPath() + "/" + GloableConfig.LuaFileListName; Debuger.Log("srcFile 111 ===" + srcFile); Debuger.Log("disFile 222 ===" + disFile); WWW www = new WWW(srcFile); yield return(www); if (www.isDone) { string tmpStr = www.text; int tmpInt = tmpStr.IndexOf("\n"); string srcArr = tmpStr.Substring(0, tmpInt); FileStream fs = new FileStream(disFile, FileMode.Open); StreamReader sw = new StreamReader(fs); string disArr = sw.ReadLine(); Debuger.Log("srcArr ===" + srcArr); Debuger.Log("disArr ===" + disArr); sw.Close(); fs.Close(); if (disArr != srcArr) { willCopyAsset = true; } } }
public static void BuildAssetBundle() { outPath = IPathTools.GetEditeABOutPath(); //判断给定的路径是否存在,注意只能判断路径(即文件夹), 不具体到文件!!! if (Directory.Exists(outPath)) { DirectoryInfo di = new DirectoryInfo(outPath); //指定是否删除子目录和文件,若为 true,则删除此目录、其子目录以及所有文件 //若为 false,目录不为空会报异常,即只能当目录为空的时候可以传 false di.Delete(true); } //创建目录 Directory.CreateDirectory(outPath); BuildPipeline.BuildAssetBundles(outPath, BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget); //重新导入有更新的资源,加入了新的文件、文件夹之类的,调用该方法可以及时显示在工程中 AssetDatabase.Refresh(); }
public static void MarkAssetBundle() { AssetDatabase.RemoveUnusedAssetBundleNames(); string path = Application.dataPath + "/Prefabs/Scenes/"; DirectoryInfo dir = new DirectoryInfo(path); //得到文件夹信息 FileSystemInfo[] fileInfo = dir.GetFileSystemInfos(); //文件夹下的所有文件包括文件夹 for (int i = 0; i < fileInfo.Length; i++) { FileSystemInfo info = fileInfo[i]; if (info is DirectoryInfo)//说明当前info是文件夹 { string tempPath = Path.Combine(path, info.Name); SceneOverView(tempPath); } } string outPath = IPathTools.GetAssetBundlePath(); CopyRecord(path, outPath); AssetDatabase.Refresh(); }
/// <summary> /// /// </summary> /// <param name="file"></param> /// <param name="headPath">Assets/Art/Scences/ScencesOne</param> /// <returns></returns> public static string GetBundlePath(FileInfo file, string headPath) { string tmpPath = file.FullName; tmpPath = IPathTools.FixedPath(tmpPath); // Debug.Log("tmpPath 111=="+ tmpPath); headPath = IPathTools.FixedPath(headPath); // Debug.Log("headPath 111==" + headPath); int assetCount = tmpPath.IndexOf(headPath); //找到的 assetCount += headPath.Length + 1; int nameCount = tmpPath.LastIndexOf(file.Name); int tmpLenght = nameCount - assetCount; int tmpCount = headPath.LastIndexOf("/"); string scencsHead = headPath.Substring(tmpCount + 1, headPath.Length - tmpCount - 1); //有路径的话 标记 全路径 if (tmpLenght > 0) { string subString = tmpPath.Substring(assetCount, tmpPath.Length - assetCount); string[] resulat = subString.Split("/".ToCharArray()); return(scencsHead + "/" + resulat[0]); } else { return(scencsHead); } }