private void Convert(string inputFile, string savePath, bool all) { SngFile sngFile = new SngFile(inputFile); if (String.IsNullOrEmpty(sngFile.Metadata.Arrangement)) { return; // Vocal } int maxDifficulty = Common.getMaxDifficulty(sngFile); int[] difficulties; if (all) { difficulties = Enumerable.Range(0, maxDifficulty + 1).ToArray(); } else // if (max) { difficulties = new int[] { maxDifficulty } }; foreach (int d in difficulties) { TabFile tabFile = new TabFile(sngFile, d); var outputFileName = (sngFile != null && sngFile.Metadata != null) ? String.Format("{0} - ", sngFile.Metadata.SongTitle) : ""; outputFileName += Path.GetFileNameWithoutExtension(inputFile); outputFileName += (difficulties.Length != 1) ? String.Format(" (level {0:00}).txt", d) : ".txt"; var outputFilePath = Path.Combine(savePath, outputFileName); using (TextWriter tw = new StreamWriter(outputFilePath)) { tw.Write(tabFile.ToString()); } } }
private static void PackageOnePath(string configFilePath, TabFile tf) { while (tf.Next()) { string strResFilePath = tf.Get <string>("FilePath"); float val = m_curIndex * 1.0f / m_totalFileCount; EditorUtility.DisplayProgressBar("Updating", "Packaging, " + Path.GetFileNameWithoutExtension(strResFilePath) + "please wait..." + val * 100 + "%", val); m_curIndex++; string realFilePath = "Assets" + "/" + strResFilePath; //sPackageManager.AddAsset(realFilePath,AssetType); realFilePath = realFilePath.Replace("\\", "/"); string[] allDependObjectPaths = AssetDatabase.GetDependencies(new string[] { realFilePath }); for (int i = 0; i < allDependObjectPaths.Length; i++) { string Ext = Path.GetExtension(allDependObjectPaths[i]).ToLower(); if (Ext == ".cs" || Ext == ".js") { continue; } AssetImporter ai = AssetImporter.GetAtPath(allDependObjectPaths[i]); if (ai == null) { UnityEngine.Debug.Log("not find Resource " + allDependObjectPaths[i]); continue; } //替换符号 allDependObjectPaths[i] = allDependObjectPaths[i].Replace("\\", "/"); var temp = allDependObjectPaths[i].Split('/'); string derictory = ""; bool isAdd = false; foreach (var s in temp) { if (isAdd) { if (derictory == "") { derictory = s; } else { derictory = derictory + "_" + s; } } else if (s.Equals("Resources") || s.Equals("Resources")) { isAdd = true; } } derictory = derictory.Replace(".", "@"); ai.assetBundleName = derictory; ai.assetBundleVariant = ""; } } }
public void TestLineParsing() { var line = "0\tobj_t_portal\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t0"; var recordsFound = 0; TabFile.ParseSpan(Encoding.Default.GetBytes(line), (in TabFileRecord record) => { recordsFound++; Assert.AreEqual(0, record[0].GetInt()); Assert.AreEqual("obj_t_portal", record[1].AsString()); for (int i = 2; i < 23; i++) { Assert.True(record[i].IsEmpty); } Assert.AreEqual(0, record[23].GetInt()); });
private void LoadDir(string dir) { var tabs = new TabList(); foreach (var file in new DirectoryInfo(dir).GetFiles()) { var tab = TabFile.OpenTab(file); if (tab != null) { tabs.Add(tab); } } dataGridView1.DataSource = tabs; foreach (DataGridViewColumn col in dataGridView1.Columns) { col.Width = col.GetPreferredWidth(DataGridViewAutoSizeColumnMode.AllCellsExceptHeader, false); } }
/// <summary> /// Create a tab page for passed tabFile. /// </summary> /// <param name="tabFile"></param> private void CreateTab(TabFile tabFile) { Log.Information("Creating tab for tabFile: " + tabFile); var tabPage = new TabPage(tabFile.TabName) { Width = 100 }; var textBox = new MainTextBox { Name = "TextBox" }; var host = new ElementHost { Name = "Host", Dock = DockStyle.Fill, Child = textBox }; tabPage.ToolTipText = tabFile.File; tabPage.Name = tabFile.Name; textBox.PreviewKeyDown += MainTextBox1_PreviewKeyDown; textBox.PreviewKeyUp += MainTextBox1_PreviewKeyUp; textBox.PreviewMouseWheel += MainTextBox1_MouseWheel; textBox.AllowDrop = true; textBox.Drop += MainTextBox1_Drop; textBox.DragEnter += MainTextBox1_DragEnter; textBox.SetDataFile(tabFile.File, _colorRules, Logger, tabPage.Name); tabPage.Controls.Add(host); tabControl1.TabPages.Add(tabPage); textBox.SetSize(host.Width, host.Height); textBox.ScrollToEnd(); _files.Add(tabFile); tabControl1.SelectTab(tabPage); }
private static void CalcNeedPackageFileCount() { for (int i = 0; i < m_configFileList.Count; i++) { string strPath = m_configFileList[i]; string fileDir = PathUtility.CombinePath("Assets", sPackConfigFileDir); fileDir = PathUtility.CombinePath(fileDir, strPath); TextAsset textAsset = AssetDatabase.LoadMainAssetAtPath(fileDir) as TextAsset; if (textAsset == null) { UnityEngine.Debug.Log(string.Format("not find {0}", strPath)); return; } //string AssetType = Path.GetFileNameWithoutExtension (strPath); fileDir = PathUtility.CombinePath(sPackConfigFileDir, strPath); string FileFullName = PathUtility.CombinePath(Application.dataPath, fileDir); StreamReader sr = new StreamReader(FileFullName); string totalStr = sr.ReadToEnd(); if (string.IsNullOrEmpty(totalStr)) { return; } TabFile tf = new TabFile(FileFullName, totalStr); if (m_configTabFileList.ContainsKey(strPath)) { UnityEngine.Debug.Log("Find Same Config File " + strPath); continue; } m_configTabFileList.Add(strPath, tf); m_totalFileCount += tf.GetCount(); } }
static void Main(string[] args) { if (args.Length == 0) { Console.Out.WriteLine("Syntax: sngtotab.exe [files]"); return; } int difficulty = Common.MAX_DIFFICULTY_ONLY; try { foreach (string filename in args) { if (filename.StartsWith("-l")) { string difficultyString = filename.Substring(2); if (difficultyString.Equals("a", StringComparison.Ordinal)) { difficulty = Common.ALL_DIFFICULTIES; } else if (difficultyString.Equals("m", StringComparison.Ordinal)) { difficulty = Common.MAX_DIFFICULTY_ONLY; } else { difficulty = int.Parse(difficultyString); } continue; } SngFile sngFile = new SngFile(filename); int maxDifficulty = Common.getMaxDifficulty(sngFile); int[] difficulties; switch (difficulty) { case Common.MAX_DIFFICULTY_ONLY: difficulties = new int[] { maxDifficulty }; break; case Common.ALL_DIFFICULTIES: difficulties = Enumerable.Range(0, maxDifficulty + 1).ToArray(); break; default: difficulties = new int[] { difficulty }; break; } foreach (int d in difficulties) { TabFile tabFile = new TabFile(sngFile, d); string outputFilename; if (filename.EndsWith(".sng")) { outputFilename = filename.Substring(0, filename.Length - 4) + "." + d + ".txt"; } else { outputFilename = filename + "." + d + ".txt"; } TextWriter tw = new StreamWriter(outputFilename); tw.Write(tabFile.ToString()); tw.Close(); } } Console.WriteLine("The conversion is complete."); } catch (Exception ex) { Console.WriteLine("Error occurred: " + ex.Message + Environment.NewLine + ex.InnerException); } }
public static TabFile CreateFromGp(Stream stream) { TabFile file = new TabFile(); var gpFile = GpFactory.CreateFile(stream); int tracksCount = gpFile.Body.Tracks.Length; int measureTrackPairsCount = gpFile.Body.MeasureTrackPairs.Length; int measureCount = gpFile.Body.Measures.Length; //tracks init for (int i = 0; i < tracksCount; i++) { //TODO: init track header Track track = new Track { Index = i, Name = gpFile.Body.Tracks[i].Name, IsDrum = gpFile.Body.Tracks[i].IsDrumsTrack, StringNumber = gpFile.Body.Tracks[i].StringNumber }; for (int j = 0; j < measureCount; j++) { // if ((j + i) % tracksCount != 0) // continue;//other track measure //TODO init measure Measure measure = new Measure(); measure.NumeratorSignature = gpFile.Body.Measures[j].NumeratorSignature; measure.DenominatorSignature = gpFile.Body.Measures[j].DenominatorSignature; measure.StringsNumber = gpFile.Body.Tracks[i].StringNumber; //TODO: ambiguous usage foreach (var gpBeat in gpFile.Body.MeasureTrackPairs[j * tracksCount + i].Beats) { //TODO init beat Beat beat = new Beat(); beat.Duration = (Tablature.Duration)gpBeat.Duration; beat.Tuplet = gpBeat.NTuplet; beat.IsDotted = gpBeat.DottedNotes; //TODO this is for 6-strings only var stringCount = gpBeat.Strings.Length; beat.Notes = new List <Note>(); for (int s = 0; s < stringCount; s++) { beat.Notes.Add(new Note() { Fret = "" }); } int noteIndex = 0; for (int stringIndex = 0; stringIndex < stringCount; stringIndex++) { var gpIdx = stringCount - 1 - stringIndex; if (!gpBeat.Strings[gpIdx]) { continue; } var effects = gpBeat.Notes[noteIndex].Effects ?? new EffectsOnNote(); beat.Notes[stringIndex] = new Note() { Fret = gpBeat.Notes[noteIndex].FretNumber.ToString(), IsLegato = effects.HammerOnPullOff, Bend = effects.Bend == null ? null : new Bend(), Slide = effects.Slide == PhoneGuitarTab.Tablature.GuitarPro.Slide.NoSlide ? null : new Slide() }; noteIndex++; } measure.Beats.Add(beat); } track.Measures.Add(measure); } file.Tracks.Add(track); } return(file); }
public static void Deploy() { string[] resConfigs = new string[] { "Other/Config/Resource/Audio.txt", "Other/Config/Resource/TextAsset.txt", "Other/Config/Resource/Model.txt", "Other/Config/Resource/Effect.txt", "Other/Config/Resource/Scene.txt", "Other/Config/Resource/UIAtlas.txt", "Other/Config/Resource/UIPanel.txt", "Other/Config/Resource/Material.txt", "Other/Config/Resource/Cursor.txt", }; // 生成MainAsset的List, 并验证配置文件是否合理 bool isMissFile = false; int MissCount = 0; List <MainAsset> mainAssets = new List <MainAsset>(); for (int i = 0; i < resConfigs.Length; i++) { TextAsset textAsset = AssetDatabase.LoadMainAssetAtPath("Assets/" + resConfigs[i]) as TextAsset; if (null == textAsset) { Log.Write(LogLevel.WARN, "config is null {0}", resConfigs[i]); return; } string strAssetType = Path.GetFileNameWithoutExtension(resConfigs[i]); TabFile tabFile = new TabFile(textAsset.name, textAsset.text); while (tabFile.Next()) { int nId = tabFile.Get <int>("id"); string strFilePath = tabFile.Get <string>("FilePath"); for (int j = 0; j < mainAssets.Count; j++) { MainAsset mainAsset = mainAssets[j]; if (mainAsset.m_strFilePath == strFilePath) { Log.Write(LogLevel.WARN, "exist two same path {0} {1}, {2}", strFilePath, mainAsset.m_strAssetType, strAssetType); return; } if (mainAsset.m_strAssetType == strAssetType && mainAsset.m_nId == nId) { Log.Write(LogLevel.WARN, "{0} repleat id {1}", strAssetType, nId); return; } } UnityEngine.Object fileObj = AssetDatabase.LoadMainAssetAtPath("Assets/" + strFilePath); if (null == fileObj) { isMissFile = true; Log.Write(LogLevel.WARN, "null id:{0} name:{1}", nId, strFilePath); MissCount++; continue; } //UnityEngine.Object[] dependObjects = EditorUtility.CollectDependencies(new UnityEngine.Object[] { fileObj }); string fileName = Path.GetFileNameWithoutExtension(strFilePath); MainAsset asset = new MainAsset(strAssetType, nId, strFilePath, fileObj, fileName); mainAssets.Add(asset); } } if (isMissFile) { Log.Write(LogLevel.WARN, "has Miss File Count {0}", MissCount); } // 分析依赖关系 SortedList <UnityEngine.Object, List <MainAsset> > depends = new SortedList <UnityEngine.Object, List <MainAsset> >(new objectCompare()); for (int i = 0; i < mainAssets.Count; i++) { MainAsset mainAsset = mainAssets[i]; UnityEngine.Object[] dependObjects = EditorUtility.CollectDependencies(new UnityEngine.Object[] { mainAsset.m_obj }); for (int j = 0; j < dependObjects.Length; j++) { UnityEngine.Object dependObj = dependObjects[j]; if (!depends.ContainsKey(dependObj)) { depends.Add(dependObj, new List <MainAsset>()); } depends[dependObj].Add(mainAsset); } } // 根据依赖关系, 分包 SortedList <List <MainAsset>, List <UnityEngine.Object> > assets = new SortedList <List <MainAsset>, List <UnityEngine.Object> >(new assetListCompare()); foreach (KeyValuePair <UnityEngine.Object, List <MainAsset> > kvp in depends) { List <UnityEngine.Object> list = null; if (!assets.ContainsKey(kvp.Value)) { list = new List <UnityEngine.Object>(); assets.Add(kvp.Value, list); } if (null == list) { list = assets[kvp.Value]; } list.Add(kvp.Key); } // 准备XML配置文件 string strXmlFile = "Other/Config/Resource/wwwResource.xml"; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(Application.dataPath + "/" + strXmlFile); xmlDoc.RemoveAll(); XmlElement root = xmlDoc.CreateElement("AssetList"); xmlDoc.AppendChild((XmlNode)root); root.SetAttribute("TotalSize", "0"); SortedList <string, XmlElement> typeXmlEle = new SortedList <string, XmlElement>(); for (int i = 0; i < mainAssets.Count; i++) { MainAsset mainAsset = mainAssets[i]; if (!typeXmlEle.ContainsKey(mainAsset.m_strAssetType)) { XmlElement typeEle = xmlDoc.CreateElement(mainAsset.m_strAssetType); typeEle.SetAttribute("TotalSize", "0"); root.AppendChild(typeEle); typeXmlEle.Add(mainAsset.m_strAssetType, typeEle); } mainAsset.m_xmlParentEle = typeXmlEle[mainAsset.m_strAssetType]; mainAsset.m_xmlSelfEle = xmlDoc.CreateElement("Asset"); mainAsset.m_xmlSelfEle.SetAttribute("Id", "0"); mainAsset.m_xmlSelfEle.SetAttribute("Version", mainAsset.m_Version.ToString()); mainAsset.m_xmlSelfEle.SetAttribute("TotalSize", "0"); mainAsset.m_xmlParentEle.AppendChild(mainAsset.m_xmlSelfEle); } //----------------------------------------------------------------------打包 BuildPipeline.PushAssetDependencies(); // 打包客户端 // string errorHead = BuildPipeline.BuildPlayer(new string[]{"Assets/Scene/JueSe.unity"}, buildDir, BuildTarget.WebPlayer, BuildOptions.None); // if(!string.IsNullOrEmpty(errorHead)) // { // Log.Write(LogLevel.ERROR,"{0}",errorHead); // return ; // } // 打包Shared int k = 0; foreach (KeyValuePair <List <MainAsset>, List <UnityEngine.Object> > kvp in assets) { List <MainAsset> listMainAsset = kvp.Key; if (listMainAsset.Count <= 1) { //MainAsset te1 = listMainAsset[0]; //Log.Write(LogLevel.INFO,"objectName is {0}",te1.m_Name); continue; } List <UnityEngine.Object> listObject = kvp.Value; int version = MainAsset.GenVersion(); string strTgtPath = "Shared/Shared" + (++k) + '_' + version.ToString() + ".asset"; bool isSucess = BuildPipeline.BuildAssetBundle(null, listObject.ToArray(), buildDir + "/" + strTgtPath, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, EditorUserBuildSettings.activeBuildTarget); if (!isSucess) { Log.Write(LogLevel.DEBUG, "build {0} failed", strTgtPath); continue; } // 设置大小观察信息 FileInfo fileInfo = new FileInfo(buildDir + "/" + strTgtPath); double fileSize = fileInfo.Length / 1024f; root.SetAttribute("TotalSize", (fileSize + Convert.ToDouble(root.GetAttribute("TotalSize"))).ToString("0.00")); for (int j = 0; j < listMainAsset.Count; j++) { MainAsset mainAsset = listMainAsset[j]; XmlElement ele = xmlDoc.CreateElement("Depend"); ele.SetAttribute("Id", "" + k); ele.SetAttribute("Version", version.ToString()); ele.SetAttribute("Size", fileSize.ToString("0.00")); mainAsset.m_xmlSelfEle.AppendChild(ele); mainAsset.m_xmlSelfEle.SetAttribute("TotalSize", (fileSize + Convert.ToDouble(mainAsset.m_xmlSelfEle.GetAttribute("TotalSize"))).ToString("0.00")); } } //打包共享 // UnityEngine.Object temp1 = AssetDatabase.LoadMainAssetAtPath("Assets/UIResources/Atlases/Common/CommonAtlas.prefab"); // BuildPipeline.BuildAssetBundle(temp1,null,buildDir + "/Shared/" + "CommonAtlas.asset",BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets); // // UnityEngine.Object temp4 = AssetDatabase.LoadMainAssetAtPath("Assets/UIResources/Font/DySongTi/songti12.prefab"); // BuildPipeline.BuildAssetBundle(temp4,null,buildDir + "/Shared/" + "Font12.asset",BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets); // // UnityEngine.Object temp5 = AssetDatabase.LoadMainAssetAtPath("Assets/UIResources/Font/DySongTi/songti14.prefab"); // BuildPipeline.BuildAssetBundle(temp5,null,buildDir + "/Shared/" + "Font14.asset",BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets); // // UnityEngine.Object temp6 = AssetDatabase.LoadMainAssetAtPath("Assets/UIResources/Font/DySongTi/songti16.prefab"); // BuildPipeline.BuildAssetBundle(temp6,null,buildDir + "/Shared/" + "Font16.asset",BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets); // // 打包mainAsset for (int i = 0; i < mainAssets.Count; i++) { MainAsset mainAsset = mainAssets[i]; // todo: 是否会出现mainAsset.m_strFilePath不一样但是strTgtPath一样的情况? string strTgtName = "" + mainAsset.m_nId + '_' + mainAsset.m_Version.ToString() + ".asset"; string strTgtPath = mainAsset.m_strAssetType + "/" + strTgtName; if ("Scene" == mainAsset.m_strAssetType) { BuildPipeline.PushAssetDependencies(); //string errorScene = BuildPipeline.BuildPlayer(new string[]{ "Assets/" + mainAsset.m_strFilePath }, buildDir + "/" + strTgtPath, // EditorUserBuildSettings.activeBuildTarget, BuildOptions.BuildAdditionalStreamedScenes); BuildPipeline.PopAssetDependencies(); //if(!string.IsNullOrEmpty(errorScene)) //{ // Log.Write(LogLevel.ERROR,"{0}",errorScene); // return ; //} } else { BuildPipeline.PushAssetDependencies(); bool isSuccess = BuildPipeline.BuildAssetBundle(mainAsset.m_obj, null, buildDir + "/" + strTgtPath, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, EditorUserBuildSettings.activeBuildTarget); BuildPipeline.PopAssetDependencies(); if (!isSuccess) { Log.Write(LogLevel.DEBUG, "build {0} failed", strTgtPath); continue; } } // 设置大小观察信息 FileInfo fileInfo = new FileInfo(buildDir + "/" + strTgtPath); double fileSize = fileInfo.Length / 1024f; root.SetAttribute("TotalSize", (fileSize + Convert.ToDouble(root.GetAttribute("TotalSize"))).ToString("0.00")); mainAsset.m_xmlSelfEle.SetAttribute("Id", "" + mainAsset.m_nId); mainAsset.m_xmlSelfEle.SetAttribute("Size", fileSize.ToString("0.00")); mainAsset.m_xmlSelfEle.SetAttribute("Name", mainAsset.OrignalName); mainAsset.m_xmlSelfEle.SetAttribute("TotalSize", (fileSize + Convert.ToDouble(mainAsset.m_xmlSelfEle.GetAttribute("TotalSize"))).ToString("0.00")); mainAsset.m_xmlParentEle.SetAttribute("TotalSize", (Convert.ToDouble(mainAsset.m_xmlParentEle.GetAttribute("TotalSize")) + Convert.ToDouble(mainAsset.m_xmlSelfEle.GetAttribute("TotalSize"))).ToString("0.00")); } BuildPipeline.PopAssetDependencies(); //---------------------------------------------------------------------- xmlDoc.Save(Application.dataPath + "/" + strXmlFile); Log.Write(LogLevel.INFO, "pack end"); }
public static void PackDBConfig() { string[] resConfigs = new string[] { "Other/Config/Resource/TextAsset.txt", }; // 生成MainAsset的List, 并验证配置文件是否合理 bool isMissFile = false; int MissCount = 0; List <MainAsset> mainAssets = new List <MainAsset>(); for (int i = 0; i < resConfigs.Length; i++) { TextAsset textAsset = AssetDatabase.LoadMainAssetAtPath("Assets/" + resConfigs[i]) as TextAsset; if (null == textAsset) { Log.Write(LogLevel.WARN, "config is null {0}", resConfigs[i]); return; } string strAssetType = Path.GetFileNameWithoutExtension(resConfigs[i]); TabFile tabFile = new TabFile(textAsset.name, textAsset.text); while (tabFile.Next()) { int nId = tabFile.Get <int>("id"); string strFilePath = tabFile.Get <string>("FilePath"); for (int j = 0; j < mainAssets.Count; j++) { MainAsset mainAsset = mainAssets[j]; if (mainAsset.m_strFilePath == strFilePath) { Log.Write(LogLevel.WARN, "{0} 同时出现在{1}, {2} 这两个配置中, 放弃本次发布", strFilePath, mainAsset.m_strAssetType, strAssetType); return; } if (mainAsset.m_strAssetType == strAssetType && mainAsset.m_nId == nId) { Log.Write(LogLevel.WARN, "{0} 配置出现了Id重复 {1}, 放弃本次发布", strAssetType, nId); return; } } UnityEngine.Object fileObj = AssetDatabase.LoadMainAssetAtPath("Assets/" + strFilePath); if (null == fileObj) { isMissFile = true; Log.Write(LogLevel.WARN, "资源为空: {0}, 放弃本次发布", strFilePath); MissCount++; continue; } string fileName = Path.GetFileNameWithoutExtension(strFilePath); MainAsset asset = new MainAsset(strAssetType, nId, strFilePath, fileObj, fileName); mainAssets.Add(asset); } } if (isMissFile) { Log.Write(LogLevel.WARN, "资源为空文件数目{0}, 放弃本次发布", MissCount); } // 准备XML配置文件 string strXmlFile = "Other/Config/Resource/wwwResource.xml"; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(Application.dataPath + "/" + strXmlFile); xmlDoc.RemoveAll(); XmlElement root = xmlDoc.CreateElement("AssetList"); xmlDoc.AppendChild((XmlNode)root); root.SetAttribute("TotalSize", "0"); SortedList <string, XmlElement> typeXmlEle = new SortedList <string, XmlElement>(); for (int i = 0; i < mainAssets.Count; i++) { MainAsset mainAsset = mainAssets[i]; if (!typeXmlEle.ContainsKey(mainAsset.m_strAssetType)) { XmlElement typeEle = xmlDoc.CreateElement(mainAsset.m_strAssetType); typeEle.SetAttribute("TotalSize", "0"); root.AppendChild(typeEle); typeXmlEle.Add(mainAsset.m_strAssetType, typeEle); } mainAsset.m_xmlParentEle = typeXmlEle[mainAsset.m_strAssetType]; mainAsset.m_xmlSelfEle = xmlDoc.CreateElement("Asset"); mainAsset.m_xmlSelfEle.SetAttribute("Id", "0"); mainAsset.m_xmlSelfEle.SetAttribute("TotalSize", "0"); mainAsset.m_xmlParentEle.AppendChild(mainAsset.m_xmlSelfEle); } BuildPipeline.PushAssetDependencies(); // 打包mainAsset for (int i = 0; i < mainAssets.Count; i++) { MainAsset mainAsset = mainAssets[i]; // todo: 是否会出现mainAsset.m_strFilePath不一样但是strTgtPath一样的情况? string strTgtName = "" + mainAsset.m_Name + ".asset"; //string strTgtName = "" + mainAsset.m_nId + ".asset"; string strTgtPath = mainAsset.m_strAssetType + "/" + strTgtName; if ("Scene" == mainAsset.m_strAssetType) { //string errorScene = BuildPipeline.BuildPlayer(new string[]{ "Assets/" + mainAsset.m_strFilePath }, buildDir + "/" + strTgtPath, // EditorUserBuildSettings.activeBuildTarget, BuildOptions.BuildAdditionalStreamedScenes); //if(!string.IsNullOrEmpty(errorScene)) //{ // Log.Write(LogLevel.ERROR,"{0}",errorScene); // return ; //} } else { BuildPipeline.BuildAssetBundle(mainAsset.m_obj, null, buildDir + "/" + strTgtPath, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, EditorUserBuildSettings.activeBuildTarget); } // 设置大小观察信息 FileInfo fileInfo = new FileInfo(buildDir + "/" + strTgtPath); double fileSize = fileInfo.Length / 1024f; root.SetAttribute("TotalSize", (fileSize + Convert.ToDouble(root.GetAttribute("TotalSize"))).ToString("0.00")); mainAsset.m_xmlSelfEle.SetAttribute("Id", "" + mainAsset.m_nId); mainAsset.m_xmlSelfEle.SetAttribute("TotalSize", (fileSize + Convert.ToDouble(mainAsset.m_xmlSelfEle.GetAttribute("TotalSize"))).ToString("0.00")); mainAsset.m_xmlParentEle.SetAttribute("TotalSize", (Convert.ToDouble(mainAsset.m_xmlParentEle.GetAttribute("TotalSize")) + Convert.ToDouble(mainAsset.m_xmlSelfEle.GetAttribute("TotalSize"))).ToString("0.00")); } BuildPipeline.PopAssetDependencies(); //---------------------------------------------------------------------- xmlDoc.Save(Application.dataPath + "/" + strXmlFile); }
public Instance(TabFile tab) { Tab = tab; }