public static Material LoadMaterial(string materialName) { AFileBase file = GameUty.FileOpen(materialName); if (!file.IsValid() || file.GetSize() == 0) { string name = materialName.Replace(@"material\", ""); file = GameUty.FileOpen(name); if (file.GetSize() == 0 || !file.IsValid()) { Debug.LogError("File not valid " + materialName); return(null); } } BinaryReader r = new BinaryReader((Stream) new MemoryStream(file.ReadAll()), System.Text.Encoding.UTF8); string str = r.ReadString(); if (str != "CM3D2_MATERIAL") { NDebug.Assert("ProcScriptBin 例外 : ヘッダーファイルが不正です。" + str); } r.ReadInt32(); r.ReadString(); Material material = AssetLoader.ReadMaterial(r, null); r.Close(); return(material); }
private static void CreateMaidClassNameMap() { if (0 < maidClassIDtoNameDic.Count) { return; } int maxVal = 0; using (AFileBase aFileBase = GameUty.FileSystem.FileOpen("maid_class_infotext.nei")) { using (CsvParser csvParser = new CsvParser()) { bool condition = csvParser.Open(aFileBase); NDebug.Assert(condition, "file open error[maid_class_infotext.nei]"); for (int i = 1; i < csvParser.max_cell_y; i++) { if (!csvParser.IsCellToExistData(0, i)) { continue; } string cellAsString = csvParser.GetCellAsString(0, i); maidClassIDtoNameDic.Add(maxVal, cellAsString); maxVal++; } } } }
public static MaidProp CreateProp(int minval, int maxval, int defval, MPN mpn, int type) { NDebug.Assert(type == 0 || type == 1 || type == 2, "プロパティオブジェクトのタイプが不正です。"); MaidProp maidProp = new MaidProp(); maidProp.name = mpn.ToString(); maidProp.type = type; maidProp.min = minval; maidProp.max = maxval; if (defval < minval) { defval = minval; } if (defval > maxval) { defval = maxval; } maidProp.value_Default = defval; maidProp.listSubProp = null; maidProp.strFileName = string.Empty; maidProp.temp_value = (maidProp.value = defval); maidProp.idx = (int)mpn; maidProp.boDut = true; maidProp.boTempDut = false; return(maidProp); }
void OnRadianAngleStepComboBoxSelectedIndexChanged(NValueChangeEventArgs arg) { NAngularScale angleScale = (NAngularScale)m_Chart.Axes[ENPolarAxis.PrimaryAngle].Scale; angleScale.MajorTickMode = ENMajorTickMode.CustomStep; switch (((NComboBox)arg.TargetNode).SelectedIndex) { case 0: angleScale.CustomStep = new NAngle(15, NUnit.Degree); break; case 1: angleScale.CustomStep = new NAngle(30, NUnit.Degree); break; case 2: angleScale.CustomStep = new NAngle(45, NUnit.Degree); break; case 3: angleScale.CustomStep = new NAngle(90, NUnit.Degree); break; default: NDebug.Assert(false); break; } }
public static void m_dicSliderPartsTypeBtnName_ext() { if (m_dicSliderPartsTypeBtnName_ext_flag) { return; } m_dicSliderPartsTypeBtnName_ext_flag = true; string text = "edit_category_define_creator.nei"; Dictionary <SceneEditInfo.EMenuCategory, int> dictionary = new Dictionary <SceneEditInfo.EMenuCategory, int>(); using (AFileBase afileBase = GameUty.FileSystemMod.FileOpen(text)) { using (CsvParser csvParser = new CsvParser()) { bool condition = csvParser.Open(afileBase); NDebug.Assert(condition, text + "\nopen failed."); for (int i = 1; i < csvParser.max_cell_y; i++) { if (csvParser.IsCellToExistData(0, i)) { int num = 0; MPN key = MPN.null_mpn; try { key = (MPN)Enum.Parse(typeof(MPN), csvParser.GetCellAsString(num++, i)); } catch { } SceneEditInfo.CCateNameType ccateNameType = new SceneEditInfo.CCateNameType(); ccateNameType.m_eMenuCate = SceneEditInfo.EMenuCategory.頭; try { ccateNameType.m_eMenuCate = (SceneEditInfo.EMenuCategory)Enum.Parse(typeof(SceneEditInfo.EMenuCategory), csvParser.GetCellAsString(num++, i)); } catch { } ccateNameType.m_eType = SceneEditInfo.CCateNameType.EType.Item; try { ccateNameType.m_eType = (SceneEditInfo.CCateNameType.EType)Enum.Parse(typeof(SceneEditInfo.CCateNameType.EType), csvParser.GetCellAsString(num++, i)); } catch { } ccateNameType.m_ePartsType = csvParser.GetCellAsString(num++, i); ccateNameType.m_strBtnPartsTypeName = csvParser.GetCellAsString(num++, i); ccateNameType.m_nIdx = 50 + i; SceneEditInfo.dicPartsTypePair_[key] = ccateNameType; } } } } }
void Search() { //EditorUtility.UnloadUnusedAssetsIgnoreManagedReferences(); EditorUtility.UnloadUnusedAssetsImmediate(); System.GC.Collect(); if (GetFolderFromSelection(Selection.activeObject)) { GetModelDataFromFolders(); } else { NDebug.Log("selection is not a folder"); } }
public void InitFromGUID(string GUID) { assetPath = AssetDatabase.GUIDToAssetPath(GUID); metaFilePath = Path.Combine(Directory.GetCurrentDirectory(), AssetDatabase.GetTextMetaFilePathFromAssetPath(assetPath)).Replace("/", "\\"); Texture2D texture = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Texture2D)) as Texture2D; if (texture == null) { NDebug.Log("NOT FOUND TEXTURE:" + assetPath); return; } width = texture.width; height = texture.height; name = texture.name; format = texture.format; instanceID = texture.GetInstanceID(); minTextureSize = Mathf.Min(width, height); maxTextureSize = Mathf.Max(width, height); TexCapacity = CalculateTextureSizeBytes(texture); StrTexCapacity = GetFileSize(TexCapacity); /*! \note GC가 작동하도록 null로 풀어야 한다. 안하면 System out of memory 오류남.*/ texture = null; TextureImporter tImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter; ///*int TexSzie = */Profiler.GetRuntimeMemorySize(tImporter); Profiler.GetRuntimeMemorySizeLong(tImporter); mipmapEnabled = tImporter.mipmapEnabled; readWriteEnabled = tImporter.isReadable; ChecksRGBEnabled = tImporter.sRGBTexture; isCheckTrensparencyEnabled = tImporter.alphaIsTransparency; //test TextureType CheckTpye = tImporter.normalmap; tImporter = null; //EditorUtility.UnloadUnusedAssetsIgnoreManagedReferences(); EditorUtility.UnloadUnusedAssetsImmediate(); CheckBuildFor(); //EditorUtility.UnloadUnusedAssetsIgnoreManagedReferences(); EditorUtility.UnloadUnusedAssetsImmediate(); }
private static void CreateEnabledYotogiClassMap() { Type yotogiClassType = typeof(Maid).Assembly.GetType("param.YotogiClassType"); MethodInfo getYotogiClassIdFromNameMethod = typeof(MaidParam).GetMethod( "GetYotogiClassIdFromName", BindingFlags.Public | BindingFlags.Static); bool isOldVersion = yotogiClassType != null; Action <string> readYotogiClasses = delegate(string fileName) { fileName += ".nei"; if (!GameUty.FileSystem.IsExistentFile(fileName)) { return; } using (AFileBase aFileBase = GameUty.FileSystem.FileOpen(fileName)) { using (CsvParser csvParser = new CsvParser()) { bool condition = csvParser.Open(aFileBase); NDebug.Assert(condition, fileName + " open failed."); for (int k = 1; k < csvParser.max_cell_y; k++) { if (!csvParser.IsCellToExistData(0, k)) { continue; } string className = csvParser.GetCellAsString(0, k); int key = isOldVersion ? (int)Enum.Parse(yotogiClassType, className, true) : (int)getYotogiClassIdFromNameMethod.Invoke(null, new object[] { className }); if (!yotogiClassToNameDic.ContainsKey(key)) { yotogiClassToNameDic.Add(key, className); } EnabledYotogiClasses.Add(key); } } } }; readYotogiClasses("yotogi_class_enabled_list"); foreach (string path in GameUty.PathList) { readYotogiClasses($"yotogi_class_enabled_list_{path}"); } EnabledYotogiClasses.Sort(); }
public static DataArray <int, byte> CreateMaidDataArray(Maid maid) { NDebug.AssertNull(maid); string guid = maid.status.guid; if (m_SaveDataMaidScenarioExecuteCountArray.ContainsKey(guid)) { return(m_SaveDataMaidScenarioExecuteCountArray[guid]); } DataArray <int, byte> dataArray = new DataArray <int, byte>(); m_SaveDataMaidScenarioExecuteCountArray.Add(guid, dataArray); /* * Debug.LogFormat("メイド「{0}」の情報を作成しました。", new object[] * { * maid.status.fullNameJpStyle * });*/ return(dataArray); }
private void LoadExample(NXmlElement element) { string groupNamespace = NExamplesHomePage.GetNamespace(element); string name = element.GetAttributeValue("name"); string type = groupNamespace + "." + element.GetAttributeValue("type"); try { type = "Nevron.Nov.Examples." + type; Type exampleType = Type.GetType(type); if (exampleType != null) { NDomType domType = NDomType.FromType(exampleType); NDebug.Assert(domType != null, "The example type:" + type + " is not a valid type"); // Create the example DateTime start = DateTime.Now; NExampleBase example = domType.CreateInstance() as NExampleBase; example.Title = name; example.Initialize(); m_Splitter.Pane2.Content = example; string stats = "Example created in: " + (DateTime.Now - start).TotalSeconds + " seconds, "; // Evaluate the example start = DateTime.Now; OwnerDocument.Evaluate(); stats += " evaluated in: " + (DateTime.Now - start).TotalSeconds + " seconds"; m_StatusLabel.Text = stats; } // Set the breadcrumb CreateBreadcrumb(element); } catch (Exception ex) { NTrace.WriteException("Failed to load example", ex); m_Splitter.Pane2.Content = new NErrorPanel("Failed to load example. Exception was: " + ex.Message); } }
void OnLocationsComboBoxSelectedIndexChanged(NValueChangeEventArgs arg) { ENLabelLocation[] locations; switch (m_LocationsComboBox.SelectedIndex) { case 0: locations = new ENLabelLocation[] { ENLabelLocation.Top }; break; case 1: locations = new ENLabelLocation[] { ENLabelLocation.Top, ENLabelLocation.Bottom }; break; default: NDebug.Assert(false); locations = null; break; } m_Bar.LabelLayout.LabelLocations = new NDomArray <ENLabelLocation>(locations); }
public static void m_dicPartsTypeCamera_ext() { if (m_dicPartsTypeCamera_ext_flag) { return; } m_dicPartsTypeCamera_ext_flag = true; string text = "edit_attention_point_define_creator.nei"; using (AFileBase afileBase = GameUty.FileSystemMod.FileOpen(text)) { using (CsvParser csvParser = new CsvParser()) { bool condition = csvParser.Open(afileBase); NDebug.Assert(condition, text + "\nopen failed."); for (int i = 1; i < csvParser.max_cell_y; i++) { if (csvParser.IsCellToExistData(0, i)) { SceneEditInfo.CamToBone value = default(SceneEditInfo.CamToBone); int num = 0; MPN key = MPN.null_mpn; try { key = (MPN)Enum.Parse(typeof(MPN), csvParser.GetCellAsString(num++, i)); } catch {} value.bone = csvParser.GetCellAsString(num++, i); value.angle = wf.Parse.Vector2(csvParser.GetCellAsString(num++, i)); value.distance = csvParser.GetCellAsReal(num++, i); SceneEditInfo.m_dicPartsTypeCamera_[key] = value; } } } } }
public static bool GetMenuItemSetUP(SceneEdit.SMenuItem mi, string f_strMenuFileName, out string IconTex, bool f_bMan = false) { IconTex = null; if (f_strMenuFileName.Contains("_zurashi")) { return(false); } if (f_strMenuFileName.Contains("_mekure")) { return(false); } f_strMenuFileName = Path.GetFileName(f_strMenuFileName); mi.m_strMenuFileName = f_strMenuFileName; mi.m_nMenuFileRID = f_strMenuFileName.ToLower().GetHashCode(); try { if (!Main.InitMenuItemScript(mi, f_strMenuFileName, f_bMan, out IconTex)) { NDebug.Assert(false, "メニュースクリプトが読めませんでした。" + f_strMenuFileName); } } catch (Exception ex) { Main.logger.LogError(string.Concat(new string[] { "GetMenuItemSetUP 例外/", f_strMenuFileName, "/", ex.Message, " StackTrace/", ex.StackTrace })); return(false); } return(true); }
/// <summary> /// 使用文件流进行脚本编译,根据类名生成dll /// </summary> /// <param name="content">脚本内容</param> /// <param name="errorAction">发生错误执行委托</param> /// <returns></returns> public static Assembly FileComplier(string content, Action <Diagnostic> errorAction = null) { StringBuilder recoder = new StringBuilder(LineFormat(ref content)); //类名获取 var node = GetTreeAndClassNames(content); //生成路径 string path = $"{LibPath}{node.ClassNames[0]}.dll"; if (DynamicDlls.ContainsKey(path)) { return(DynamicDlls[path]); } //写入分析树 //SyntaxTree tree = SyntaxFactory.ParseSyntaxTree(content); //创建语言编译 CSharpCompilation compilation = CSharpCompilation.Create( node.ClassNames[0], options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary), syntaxTrees: new[] { node.Tree }, references: References); //编译到文件 EmitResult fileResult = null; try { fileResult = compilation.Emit(path); } catch (Exception ex) { if (ex is IOException) { int loop = 0; while (!DynamicDlls.ContainsKey(path)) { Thread.Sleep(200); loop += 1; } NDebug.Warning(node.ClassNames[0], $" I/O Delay :\t检测到争用,延迟{loop * 200}ms调用;\r\n"); return(DynamicDlls[path]); } return(null); } if (fileResult.Success) { References.Add(MetadataReference.CreateFromFile(path)); //为了实现动态中的动态,使用文件加载模式常驻内存 var result = Assembly.LoadFrom(path); for (int i = 0; i < node.ClassNames.Length; i += 1) { ClassMapping[node.ClassNames[i]] = result; } if (NDebug.UseLog) { recoder.AppendLine("\r\n\r\n------------------------------------------succeed-------------------------------------------"); recoder.AppendLine($"\r\n Lauguage :\t{compilation.Language}___{compilation.LanguageVersion}"); recoder.AppendLine($"\r\n Target :\t\t{node.ClassNames[0]}"); recoder.AppendLine($"\r\n Path :\t\t{path}"); recoder.AppendLine($"\r\n Assembly : \t{result.FullName}"); recoder.AppendLine("\r\n----------------------------------------------------------------------------------------------"); NDebug.Succeed("Succeed : " + node.ClassNames[0], recoder.ToString()); } DynamicDlls[path] = result; return(result); } else { if (NDebug.UseLog) { recoder.AppendLine("\r\n\r\n------------------------------------------error----------------------------------------------"); recoder.AppendLine($"\r\n Lauguage :\t{compilation.Language}___{compilation.LanguageVersion}"); recoder.AppendLine($"\r\n Target:\t\t{node.ClassNames[0]}"); recoder.AppendLine($"\r\n Error:\t\t共{fileResult.Diagnostics.Length}处错误!"); } foreach (var item in fileResult.Diagnostics) { if (NDebug.UseLog) { var temp = item.Location.GetLineSpan().StartLinePosition; var result = GetErrorString(content, item.Location.GetLineSpan()); recoder.AppendLine($"\t\t第{temp.Line}行,第{temp.Character}个字符: 内容【{result}】 {item.GetMessage()}"); } errorAction?.Invoke(item); } recoder.AppendLine("\r\n---------------------------------------------------------------------------------------------"); NDebug.Error("Error : " + node.ClassNames[0], recoder.ToString()); } return(null); }
/// <summary> /// 使用内存流进行脚本编译 /// </summary> /// <param name="content">脚本内容</param> /// <param name="errorAction">发生错误执行委托</param> /// <returns></returns> public static Assembly StreamComplier(string content, Action <Diagnostic> errorAction = null) { StringBuilder recoder = new StringBuilder(LineFormat(ref content)); var node = GetTreeAndClassName(content); //创建语言编译 CSharpCompilation compilation = CSharpCompilation.Create( node.ClassName, options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary), syntaxTrees: new[] { node.Tree }, references: References); //编译并生成程序集 using (MemoryStream stream = new MemoryStream()) { var fileResult = compilation.Emit(stream); if (fileResult.Success) { var result = Assembly.Load(stream.GetBuffer()); if (NDebug.UseLog) { recoder.AppendLine("\r\n\r\n------------------------------------------succeed-------------------------------------------"); recoder.AppendLine($"\r\n Lauguage :\t{compilation.Language}___{compilation.LanguageVersion}"); recoder.AppendLine($"\r\n Target :\t\t{node.ClassName}"); recoder.AppendLine($"\r\n Size :\t\t{stream.Length}"); recoder.AppendLine($"\r\n Assembly : \t{result.FullName}"); recoder.AppendLine("\r\n----------------------------------------------------------------------------------------------"); NDebug.Succeed("Succeed : " + node.ClassName, recoder.ToString()); } return(result); } else { if (NDebug.UseLog) { recoder.AppendLine("\r\n\r\n------------------------------------------error----------------------------------------------"); recoder.AppendLine($"\r\n Lauguage :\t{compilation.Language}___{compilation.LanguageVersion}"); recoder.AppendLine($"\r\n Target:\t\t{node.ClassName}"); recoder.AppendLine($"\r\n Error:\t\t共{fileResult.Diagnostics.Length}处错误!"); } //错误处理 foreach (var item in fileResult.Diagnostics) { if (NDebug.UseLog) { var temp = item.Location.GetLineSpan().StartLinePosition; var result = GetErrorString(content, item.Location.GetLineSpan()); recoder.AppendLine($"\t\t第{temp.Line}行,第{temp.Character}个字符: 内容【{result}】 {item.GetMessage()}"); } errorAction?.Invoke(item); } if (NDebug.UseLog) { recoder.AppendLine("\r\n---------------------------------------------------------------------------------------------"); NDebug.Error("Error : " + node.ClassName, recoder.ToString()); } } } return(null); }
/// <summary> /// 使用内存流进行脚本编译 /// </summary> /// <param name="content">脚本内容</param> /// <param name="className">指定类名</param> /// <param name="errorAction">发生错误执行委托</param> /// <returns></returns> public static Assembly StreamComplier(string content, string className = null, Action <string> errorAction = null) { #if DEBUG StringBuilder recoder = new StringBuilder(content); #endif //写入分析树 SyntaxTree tree = SyntaxFactory.ParseSyntaxTree(content); //创建语言编译 CSharpCompilation compilation = CSharpCompilation.Create( className, options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary), syntaxTrees: new[] { tree }, references: References); //锁住内容 lock (content) { //编译并生成程序集 using (MemoryStream stream = new MemoryStream()) { var fileResult = compilation.Emit(stream); if (fileResult.Success) { var result = Assembly.Load(stream.GetBuffer()); #if DEBUG recoder.AppendLine("\r\n\r\n------------------------------------------succeed-------------------------------------------"); recoder.AppendLine($"\r\n Target :\t\t{className}"); recoder.AppendLine($"\r\n Size :\t\t{stream.Length}"); recoder.AppendLine($"\r\n Assembly : \t{result.FullName}"); recoder.AppendLine("\r\n----------------------------------------------------------------------------------------------"); NDebug.Show($"Builder Assembly Succeed : {result.FullName}"); NDebug.FileRecoder("Succeed : " + className, recoder.ToString()); #endif return(result); } else { #if DEBUG recoder.AppendLine("\r\n\r\n------------------------------------------error----------------------------------------------"); recoder.AppendLine($"\r\n Target:\t\t{className}"); recoder.AppendLine($"\r\n Error:"); #endif //错误处理 foreach (var item in fileResult.Diagnostics) { #if DEBUG recoder.AppendLine("\t\t" + item.GetMessage()); #endif errorAction?.Invoke(item.GetMessage()); } #if DEBUG recoder.AppendLine("\r\n---------------------------------------------------------------------------------------------"); #endif NDebug.FileRecoder("Error : " + className, recoder.ToString()); } } } return(null); }
private void Exec_Check() { if (string.IsNullOrEmpty(_selectedPath) || string.IsNullOrEmpty(_destPath)) { EditorUtility.DisplayDialog("오류", "경로를 확인해 주세요", "확인"); return; } _refList.Clear(); _detailList.Clear(); List <string> srcGuidList = new List <string>(); srcGuidList.Clear(); if (_refType == REF_TYPE.TEXTURE) { srcGuidList.AddRange(AssetDatabase.FindAssets("t:Texture", new string[] { _selectedPath })); } else if (_refType == REF_TYPE.MATERIAL) { srcGuidList.AddRange(AssetDatabase.FindAssets("t:Material", new string[] { _selectedPath })); } else if (_refType == REF_TYPE.ANIMATIONCLIP) { srcGuidList.AddRange(AssetDatabase.FindAssets("t:AnimationClip", new string[] { _selectedPath })); } else if (_refType == REF_TYPE.SHADER) { srcGuidList.AddRange(AssetDatabase.FindAssets("t:Shader", new string[] { _selectedPath })); } else { srcGuidList.AddRange(AssetDatabase.FindAssets("t:Texture t:Material t:AnimationClip", new string[] { _selectedPath })); } List <string> targetGuidList = new List <string>(); targetGuidList.Clear(); if (_refType == REF_TYPE.TEXTURE) { targetGuidList.AddRange(AssetDatabase.FindAssets("t:Material", new string[] { _destPath })); } else if (_refType == REF_TYPE.MATERIAL) { targetGuidList.AddRange(AssetDatabase.FindAssets("t:Prefab", new string[] { _destPath })); } else if (_refType == REF_TYPE.ANIMATIONCLIP) { targetGuidList.AddRange(AssetDatabase.FindAssets("t:Prefab", new string[] { _destPath })); } else if (_refType == REF_TYPE.SHADER) { targetGuidList.AddRange(AssetDatabase.FindAssets("t:Material", new string[] { _destPath })); } else { targetGuidList.AddRange(AssetDatabase.FindAssets("t:Prefab", new string[] { _destPath })); } foreach (string guid in srcGuidList) { string assetPath = AssetDatabase.GUIDToAssetPath(guid); Object obj = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Object)); if (_refType == REF_TYPE.TEXTURE) { if (obj is Texture) { _refList[obj.GetInstanceID()] = obj; } } else if (_refType == REF_TYPE.MATERIAL) { if (obj is Material) { _refList[obj.GetInstanceID()] = obj; } } else if (_refType == REF_TYPE.ANIMATIONCLIP) { if (obj is AnimationClip) { _refList[obj.GetInstanceID()] = obj; } } else if (_refType == REF_TYPE.SHADER) { if (obj is Shader) { _refList[obj.GetInstanceID()] = obj; } } else { _refList[obj.GetInstanceID()] = obj; } foreach (string guids in targetGuidList) { // 자기 자신의 참조는 제외 if (guid == guids) { continue; } string path = AssetDatabase.GUIDToAssetPath(guids); Object ob = AssetDatabase.LoadAssetAtPath(path, typeof(Object)); Object[] g = new Object[] { ob }; Object[] depndencies = EditorUtility.CollectDependencies(g); foreach (Object o in depndencies) { try { if (null != o && o.GetInstanceID() == obj.GetInstanceID()) { if (_detailList.ContainsKey(obj.GetInstanceID())) { ResourceDetailInfo info = new ResourceDetailInfo(); info.name = ob.name; info.instanceID = ob.GetInstanceID(); _detailList[obj.GetInstanceID()].Add(info); } else { List <ResourceDetailInfo> list = new List <ResourceDetailInfo>(); ResourceDetailInfo info = new ResourceDetailInfo(); info.name = ob.name; info.instanceID = ob.GetInstanceID(); list.Add(info); _detailList[obj.GetInstanceID()] = list; } break; } } catch (System.Exception e) { NDebug.Log(e.Message); } } } } }
/// <summary> /// 使用文件流进行脚本编译,根据类名生成dll /// </summary> /// <param name="content">脚本内容</param> /// <param name="className">指定类名</param> /// <param name="errorAction">发生错误执行委托</param> /// <returns></returns> public static Assembly FileComplier(string content, string className = null, Action <Diagnostic> errorAction = null) { #if DEBUG StringBuilder recoder = new StringBuilder(LineFormat(ref content)); #endif //类名获取 if (className == null) { className = GetClassName(content); } //生成路径 string path = $"{LibPath}{className}.dll"; NDebug.Show("Writing:" + path); if (DynamicDlls.ContainsKey(path)) { return(DynamicDlls[path]); } //写入分析树 SyntaxTree tree = SyntaxFactory.ParseSyntaxTree(content); //创建语言编译 CSharpCompilation compilation = CSharpCompilation.Create( className, options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary), syntaxTrees: new[] { tree }, references: References); //锁住内容 lock (content) { //再次检查缓存,解决并发问题 if (DynamicDlls.ContainsKey(path)) { return(DynamicDlls[path]); } //编译到文件 var fileResult = compilation.Emit(path); if (fileResult.Success) { References.Add(MetadataReference.CreateFromFile(path)); //为了实现动态中的动态,使用文件加载模式常驻内存 var result = Assembly.LoadFrom(path); #if DEBUG recoder.AppendLine("\r\n\r\n------------------------------------------succeed-------------------------------------------"); recoder.AppendLine($"\r\n Lauguage :\t{compilation.Language}___{compilation.LanguageVersion}"); recoder.AppendLine($"\r\n Target :\t\t{className}"); recoder.AppendLine($"\r\n Path :\t\t{path}"); recoder.AppendLine($"\r\n Assembly : \t{result.FullName}"); recoder.AppendLine("\r\n----------------------------------------------------------------------------------------------"); NDebug.Show($"Builder Assembly Succeed : {result.FullName}"); NDebug.SucceedRecoder("Succeed : " + className, recoder.ToString()); #endif DynamicDlls[path] = result; return(result); } else { #if DEBUG recoder.AppendLine("\r\n\r\n------------------------------------------error----------------------------------------------"); recoder.AppendLine($"\r\n Lauguage :\t{compilation.Language}___{compilation.LanguageVersion}"); recoder.AppendLine($"\r\n Target:\t\t{className}"); recoder.AppendLine($"\r\n Error:\t\t共{fileResult.Diagnostics.Length}处错误!"); #endif foreach (var item in fileResult.Diagnostics) { #if DEBUG var temp = item.Location.GetLineSpan().StartLinePosition; var result = GetErrorString(content, item.Location.GetLineSpan()); recoder.AppendLine($"\t\t第{temp.Line}行,第{temp.Character}个字符: 内容【{result}】 {item.GetMessage()}"); #endif errorAction?.Invoke(item); } #if DEBUG recoder.AppendLine("\r\n---------------------------------------------------------------------------------------------"); NDebug.ErrorRecoder("Error : " + className, recoder.ToString()); #endif } } return(null); }
// Token: 0x0600006A RID: 106 RVA: 0x000B857C File Offset: 0x000B757C public static Material ReadMaterial(BinaryReader r, TBodySkin bodyskin, Material existmat, string filename) { existmat = null; if (ImportCM2.m_hashPriorityMaterials == null) { ImportCM2.m_hashPriorityMaterials = new Dictionary <int, KeyValuePair <string, float> >(); string[] list = GameUty.FileSystem.GetList("prioritymaterial", ListType.AllFile); if (list != null && 0 < list.Length) { for (int i = 0; i < list.Length; i++) { if (Path.GetExtension(list[i]) == ".pmat") { string text = list[i]; using (AFileBase afileBase = GameUty.FileOpen(text, null)) { NDebug.Assert(afileBase.IsValid(), text + "を開けませんでした"); byte[] buffer = afileBase.ReadAll(); using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(buffer), Encoding.UTF8)) { string a = binaryReader.ReadString(); NDebug.Assert(a == "CM3D2_PMATERIAL", "ヘッダーエラー\n" + text); int num = binaryReader.ReadInt32(); int key = binaryReader.ReadInt32(); string key2 = binaryReader.ReadString(); float value = binaryReader.ReadSingle(); NDebug.Assert(!ImportCM2.m_hashPriorityMaterials.ContainsKey(key), "すでにハッシュが登録されています"); ImportCM2.m_hashPriorityMaterials.Add(key, new KeyValuePair <string, float>(key2, value)); } } } } } } string name = r.ReadString(); string text2 = r.ReadString(); string str = r.ReadString(); string path = "DefMaterial/" + str; Material material2; if (existmat == null) { Material material = Resources.Load(path, typeof(Material)) as Material; if (material == null) { return(material); } material2 = UnityEngine.Object.Instantiate <Material>(material); } else { material2 = existmat; NDebug.Assert(material2.shader.name == text2, "マテリアル入れ替えエラー。違うシェーダーに入れようとしました。 " + text2 + " -> " + material2.shader.name); } material2.name = name; int hashCode = material2.name.GetHashCode(); if (ImportCM2.m_hashPriorityMaterials != null && ImportCM2.m_hashPriorityMaterials.ContainsKey(hashCode)) { KeyValuePair <string, float> keyValuePair = ImportCM2.m_hashPriorityMaterials[hashCode]; if (keyValuePair.Key == material2.name) { material2.SetFloat("_SetManualRenderQueue", keyValuePair.Value); material2.renderQueue = (int)keyValuePair.Value; } } Vector2 value2; Vector2 value3; Color value4; Vector4 value5; for (;;) { string a2 = r.ReadString(); if (a2 == "end") { break; } string name2 = r.ReadString(); if (a2 == "tex") { string a3 = r.ReadString(); if (a3 == "null") { material2.SetTexture(name2, null); } else if (a3 == "tex2d") { try { string text3 = r.ReadString(); string text4 = r.ReadString(); byte[] data = ImportCM.LoadTexture(GameUty.FileSystem, text3 + ".tex", false).data; value2.x = r.ReadSingle(); value2.y = r.ReadSingle(); value3.x = r.ReadSingle(); value3.y = r.ReadSingle(); if (filename == null || !filename.Contains(".mate")) { Texture2D texture2D = new Texture2D(1, 1, TextureFormat.RGBA32, false); texture2D.LoadImage(data); texture2D.name = text3; texture2D.wrapMode = TextureWrapMode.Clamp; material2.SetTexture(name2, texture2D); material2.SetTextureOffset(name2, value2); material2.SetTextureScale(name2, value3); } } catch { break; } } else if (a3 == "texRT") { string text5 = r.ReadString(); string text6 = r.ReadString(); } } else if (a2 == "col") { value4.r = r.ReadSingle(); value4.g = r.ReadSingle(); value4.b = r.ReadSingle(); value4.a = r.ReadSingle(); material2.SetColor(name2, value4); } else if (a2 == "vec") { value5.x = r.ReadSingle(); value5.y = r.ReadSingle(); value5.z = r.ReadSingle(); value5.w = r.ReadSingle(); material2.SetVector(name2, value5); } else if (a2 == "f") { float value6 = r.ReadSingle(); material2.SetFloat(name2, value6); } } if (filename != null && filename.Contains(".mate")) { try { using (AFileBase afileBase = GameUty.FileOpen(filename, null)) { if (ImportCM2.m_matTempFile == null) { ImportCM2.m_matTempFile = new byte[Math.Max(10000, afileBase.GetSize())]; } else if (ImportCM2.m_matTempFile.Length < afileBase.GetSize()) { ImportCM2.m_matTempFile = new byte[afileBase.GetSize()]; } afileBase.Read(ref ImportCM2.m_matTempFile, afileBase.GetSize()); } } catch { } BinaryReader binaryReader2 = new BinaryReader(new MemoryStream(ImportCM2.m_matTempFile), Encoding.UTF8); string text7 = binaryReader2.ReadString(); NDebug.Assert(text7 == "CM3D2_MATERIAL", "ProcScriptBin 例外 : ヘッダーファイルが不正です。" + text7); int num2 = binaryReader2.ReadInt32(); string text8 = binaryReader2.ReadString(); r = binaryReader2; name = r.ReadString(); text2 = r.ReadString(); str = r.ReadString(); path = "DefMaterial/" + str; if (existmat == null) { Material material = Resources.Load(path, typeof(Material)) as Material; if (material == null) { return(material); } material2 = UnityEngine.Object.Instantiate <Material>(material); } else { material2 = existmat; NDebug.Assert(material2.shader.name == text2, "マテリアル入れ替えエラー。違うシェーダーに入れようとしました。 " + text2 + " -> " + material2.shader.name); } material2.name = name; hashCode = material2.name.GetHashCode(); if (ImportCM2.m_hashPriorityMaterials != null && ImportCM2.m_hashPriorityMaterials.ContainsKey(hashCode)) { KeyValuePair <string, float> keyValuePair = ImportCM2.m_hashPriorityMaterials[hashCode]; if (keyValuePair.Key == material2.name) { material2.SetFloat("_SetManualRenderQueue", keyValuePair.Value); material2.renderQueue = (int)keyValuePair.Value; } } for (;;) { string a2 = r.ReadString(); if (a2 == "end") { break; } string name2 = r.ReadString(); if (a2 == "tex") { string a3 = r.ReadString(); if (a3 == "null") { material2.SetTexture(name2, null); } else if (a3 == "tex2d") { try { string text3 = r.ReadString(); string text4 = r.ReadString(); byte[] data = ImportCM.LoadTexture(GameUty.FileSystem, text3 + ".tex", false).data; Texture2D texture2D = new Texture2D(1, 1, TextureFormat.RGBA32, false); texture2D.LoadImage(data); texture2D.name = text3; texture2D.wrapMode = TextureWrapMode.Clamp; material2.SetTexture(name2, texture2D); value2.x = r.ReadSingle(); value2.y = r.ReadSingle(); material2.SetTextureOffset(name2, value2); value3.x = r.ReadSingle(); value3.y = r.ReadSingle(); material2.SetTextureScale(name2, value3); } catch { break; } } else if (a3 == "texRT") { string text5 = r.ReadString(); string text6 = r.ReadString(); } } else if (a2 == "col") { value4.r = r.ReadSingle(); value4.g = r.ReadSingle(); value4.b = r.ReadSingle(); value4.a = r.ReadSingle(); material2.SetColor(name2, value4); } else if (a2 == "vec") { value5.x = r.ReadSingle(); value5.y = r.ReadSingle(); value5.z = r.ReadSingle(); value5.w = r.ReadSingle(); material2.SetVector(name2, value5); } else if (a2 == "f") { float value6 = r.ReadSingle(); material2.SetFloat(name2, value6); } } } return(material2); }
// Token: 0x06000069 RID: 105 RVA: 0x000B7D04 File Offset: 0x000B6D04 public static GameObject LoadSkinMesh_R(string filename, string[] filename2, string slotname, TBodySkin bodyskin, int layer) { try { using (AFileBase afileBase = GameUty.FileOpen(filename, null)) { if (ImportCM2.m_skinTempFile == null) { ImportCM2.m_skinTempFile = new byte[Math.Max(500000, afileBase.GetSize())]; } else if (ImportCM2.m_skinTempFile.Length < afileBase.GetSize()) { ImportCM2.m_skinTempFile = new byte[afileBase.GetSize()]; } afileBase.Read(ref ImportCM2.m_skinTempFile, afileBase.GetSize()); } } catch (Exception ex) { NDebug.Assert("ファイルが開けませんでした。" + filename + "\n" + ex.Message, false); } BinaryReader binaryReader = new BinaryReader(new MemoryStream(ImportCM2.m_skinTempFile), Encoding.UTF8); TBodySkin.OriVert oriVert = bodyskin.m_OriVert; GameObject gameObject = UnityEngine.Object.Instantiate(Resources.Load("seed")) as GameObject; gameObject.layer = layer; GameObject gameObject2 = null; Hashtable hashtable = new Hashtable(); string text = binaryReader.ReadString(); if (text != "CM3D2_MESH") { NDebug.Assert("LoadSkinMesh_R 例外 : ヘッダーファイルが不正です。" + text, false); } int num = binaryReader.ReadInt32(); string str = binaryReader.ReadString(); gameObject.name = "_SM_" + str; string b = binaryReader.ReadString(); int num2 = binaryReader.ReadInt32(); List <GameObject> list = new List <GameObject>(); for (int i = 0; i < num2; i++) { GameObject gameObject3 = UnityEngine.Object.Instantiate(Resources.Load("seed")) as GameObject; gameObject3.layer = layer; gameObject3.name = binaryReader.ReadString(); list.Add(gameObject3); if (gameObject3.name == b) { gameObject2 = gameObject3; } hashtable[gameObject3.name] = gameObject3; bool flag = binaryReader.ReadByte() != 0; if (flag) { GameObject gameObject4 = UnityEngine.Object.Instantiate(Resources.Load("seed")) as GameObject; gameObject4.name = gameObject3.name + "_SCL_"; gameObject4.transform.parent = gameObject3.transform; hashtable[gameObject3.name + "&_SCL_"] = gameObject4; } } for (int j = 0; j < num2; j++) { int num3 = binaryReader.ReadInt32(); if (num3 >= 0) { list[j].transform.parent = list[num3].transform; } else { list[j].transform.parent = gameObject.transform; } } for (int k = 0; k < num2; k++) { Transform transform = list[k].transform; float x = binaryReader.ReadSingle(); float y = binaryReader.ReadSingle(); float z = binaryReader.ReadSingle(); transform.localPosition = new Vector3(x, y, z); float x2 = binaryReader.ReadSingle(); float y2 = binaryReader.ReadSingle(); float z2 = binaryReader.ReadSingle(); float w = binaryReader.ReadSingle(); transform.localRotation = new Quaternion(x2, y2, z2, w); if (2001 <= num) { bool flag2 = binaryReader.ReadBoolean(); if (flag2) { float x3 = binaryReader.ReadSingle(); float y3 = binaryReader.ReadSingle(); float z3 = binaryReader.ReadSingle(); transform.localScale = new Vector3(x3, y3, z3); } } } int num4 = binaryReader.ReadInt32(); int num5 = binaryReader.ReadInt32(); int num6 = binaryReader.ReadInt32(); oriVert.VCount = num4; oriVert.nSubMeshCount = num5; gameObject2.AddComponent(typeof(SkinnedMeshRenderer)); gameObject.AddComponent(typeof(Animation)); SkinnedMeshRenderer skinnedMeshRenderer = gameObject2.GetComponent <Renderer>() as SkinnedMeshRenderer; skinnedMeshRenderer.updateWhenOffscreen = true; Transform[] array = new Transform[num6]; for (int l = 0; l < num6; l++) { string text2 = binaryReader.ReadString(); if (hashtable.ContainsKey(text2)) { GameObject gameObject5; if (hashtable.ContainsKey(text2 + "&_SCL_")) { gameObject5 = (GameObject)hashtable[text2 + "&_SCL_"]; } else { gameObject5 = (GameObject)hashtable[text2]; } array[l] = gameObject5.transform; } } skinnedMeshRenderer.bones = array; Mesh mesh = new Mesh(); skinnedMeshRenderer.sharedMesh = mesh; Mesh mesh2 = mesh; Matrix4x4[] array2 = new Matrix4x4[num6]; for (int m = 0; m < num6; m++) { for (int n = 0; n < 16; n++) { array2[m][n] = binaryReader.ReadSingle(); } } mesh2.bindposes = array2; Vector3[] array3 = new Vector3[num4]; Vector3[] array4 = new Vector3[num4]; Vector2[] array5 = new Vector2[num4]; BoneWeight[] array6 = new BoneWeight[num4]; for (int num7 = 0; num7 < num4; num7++) { float num8 = binaryReader.ReadSingle(); float num9 = binaryReader.ReadSingle(); float new_z = binaryReader.ReadSingle(); array3[num7].Set(num8, num9, new_z); num8 = binaryReader.ReadSingle(); num9 = binaryReader.ReadSingle(); new_z = binaryReader.ReadSingle(); array4[num7].Set(num8, num9, new_z); num8 = binaryReader.ReadSingle(); num9 = binaryReader.ReadSingle(); array5[num7].Set(num8, num9); } mesh2.vertices = array3; mesh2.normals = array4; mesh2.uv = array5; oriVert.vOriVert = array3; oriVert.vOriNorm = array4; int num10 = binaryReader.ReadInt32(); if (num10 > 0) { Vector4[] array7 = new Vector4[num10]; for (int num11 = 0; num11 < num10; num11++) { float x3 = binaryReader.ReadSingle(); float y3 = binaryReader.ReadSingle(); float z3 = binaryReader.ReadSingle(); float w2 = binaryReader.ReadSingle(); array7[num11] = new Vector4(x3, y3, z3, w2); } mesh2.tangents = array7; } for (int num12 = 0; num12 < num4; num12++) { array6[num12].boneIndex0 = (int)binaryReader.ReadUInt16(); array6[num12].boneIndex1 = (int)binaryReader.ReadUInt16(); array6[num12].boneIndex2 = (int)binaryReader.ReadUInt16(); array6[num12].boneIndex3 = (int)binaryReader.ReadUInt16(); array6[num12].weight0 = binaryReader.ReadSingle(); array6[num12].weight1 = binaryReader.ReadSingle(); array6[num12].weight2 = binaryReader.ReadSingle(); array6[num12].weight3 = binaryReader.ReadSingle(); } mesh2.boneWeights = array6; mesh2.subMeshCount = num5; oriVert.bwWeight = array6; oriVert.nSubMeshCount = num5; oriVert.nSubMeshOriTri = new int[num5][]; for (int num13 = 0; num13 < num5; num13++) { int num14 = binaryReader.ReadInt32(); int[] array8 = new int[num14]; for (int num15 = 0; num15 < num14; num15++) { array8[num15] = (int)binaryReader.ReadUInt16(); } oriVert.nSubMeshOriTri[num13] = array8; mesh2.SetTriangles(array8, num13); } int num16 = binaryReader.ReadInt32(); Material[] array9 = new Material[num16]; for (int num17 = 0; num17 < num16; num17++) { Material material = ImportCM2.ReadMaterial(binaryReader, bodyskin, null, filename2[1 + num17]); array9[num17] = material; } skinnedMeshRenderer.materials = array9; binaryReader.Close(); return(gameObject); }
private static bool readMenuProp(string stringCom, string[] stringList, ref MaidParts.PARTS_COLOR partsColor, ref MenuInfo mi) { if (stringCom == "name") { string str3 = stringList[1]; string empty2 = string.Empty; string empty3 = string.Empty; int index; for (index = 0; index < str3.Length && (int)str3[index] != 12288 && (int)str3[index] != 32; ++index) { empty2 += str3[index]; } for (; index < str3.Length; ++index) { empty3 += str3[index]; } mi.menuName = empty2; } else if (stringCom == "setumei") { mi.menuInfo = stringList[1]; mi.menuInfo = mi.menuInfo.Replace("《改行》", "\n"); } else if (stringCom == "category") { string lower = stringList[1].ToLower(); try { mi.partCategory = (MPN)Enum.Parse(typeof(MPN), lower); } catch { UnityEngine.Debug.LogWarning("カテゴリがありません。" + stringList[1]); mi.partCategory = MPN.null_mpn; } } else if (stringCom == "color_set") { try { mi.colorSetCategory = (MPN)Enum.Parse(typeof(MPN), stringList[1].ToLower()); } catch { UnityEngine.Debug.LogWarning((object)("カテゴリがありません。" + stringList[1].ToLower())); } if (stringList.Length >= 3) { mi.menuNameInColorSet = stringList[2].ToLower(); } } else if (stringCom == "tex" || stringCom == "テクスチャ変更") { string slotname2 = stringList[1]; int matno = int.Parse(stringList[2]); string prop_name = stringList[3]; string filename1 = stringList[4]; partsColor = MaidParts.PARTS_COLOR.NONE; if (stringList.Length == 6) { string str5 = stringList[5]; try { partsColor = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), str5.ToUpper()); } catch { NDebug.Assert("無限色IDがありません。" + str5); } } mi.textureChanges.Add(new TextureChangeInfo(slotname2, matno, prop_name, filename1, partsColor)); // partsColor = MaidParts.PARTS_COLOR.NONE; // body0.ChangeTex(slotname2, matno, prop_name, filename1, (Dictionary<string, byte[]>) null, partsColor); } else if (stringCom == "マテリアル変更") { string strSlotName = stringList[1]; int nMatNo = int.Parse(stringList[2]); string strFileName = stringList[3]; mi.materialChanges.Add(new MaterialChangeInfo(strSlotName, nMatNo, strFileName)); } else { return(true); } return(false); }
public static MenuInfo LoadMenu(string menuFileName) { AFileBase file = GameUty.FileOpen(menuFileName); if (!file.IsValid() || file.GetSize() == 0) { string name = menuFileName.Replace(@"menu\", ""); file = GameUty.FileOpen(name); if (file.GetSize() == 0 || !file.IsValid()) { name = menuFileName.Replace(@"menu\man\", ""); file = GameUty.FileOpen(name); if (file.GetSize() == 0 || !file.IsValid()) { throw new FileNotFoundException(name); } } } MenuInfo mi = new MenuInfo(); mi.menuFileName = menuFileName; BinaryReader binaryReader = new BinaryReader(new MemoryStream(file.ReadAll()), System.Text.Encoding.UTF8); string str1 = binaryReader.ReadString(); NDebug.Assert(str1 == "CM3D2_MENU", "ProcScriptBin 例外 : ヘッダーファイルが不正です。" + str1); binaryReader.ReadInt32(); string path = binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); long num1 = (long)binaryReader.ReadInt32(); string sss = string.Empty; string str2 = string.Empty; string empty1 = string.Empty; try { while (true) { string stringCom; string[] stringList; do { do { do { MaidParts.PARTS_COLOR partsColor = MaidParts.PARTS_COLOR.NONE; do { sss = readCom(binaryReader); if (sss == null) { goto label_61; } stringCom = UTY.GetStringCom(sss); stringList = UTY.GetStringList(sss); if (readMenuProp(stringCom, stringList, ref partsColor, ref mi) == true) { goto label_40; } }while (stringList.Length != 6); string str4 = stringList[5]; try { partsColor = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), str4.ToUpper()); } catch { NDebug.Assert("無限色IDがありません。" + str4); } mi.partsColor = partsColor; continue; label_40: if (stringCom == "icon" || stringCom == "icons") { mi.iconTextureName = stringList[1]; } }while (stringCom == "iconl" || stringCom == "setstr" || stringCom == "アイテムパラメータ"); if (stringCom == "saveitem") { string str3 = stringList[1]; if (str3 == string.Empty) { UnityEngine.Debug.LogError("err SaveItem \"" + str3); } if (str3 == null) { UnityEngine.Debug.LogError("err SaveItem null=\"" + str3); } } }while (stringCom == "catno"); if (stringCom == "additem") { mi.modelName = stringList[1]; } else if (stringCom == "delitem" || stringCom == "unsetitem") { mi.delOnly = true; } else if (stringCom == "priority") { mi.priority = float.Parse(stringList[1]); } }while (!(stringCom == "メニューフォルダ") || !(stringList[1].ToLower() == "man")); mi.isMan = true; } } catch { UnityEngine.Debug.LogError("Failed to parse menu file " + Path.GetFileName(path)); // UnityEngine.Debug.LogError(("Exception " + Path.GetFileName(path) + " 現在処理中だった行 = " + sss + " 以前の行 = " + str2 + " " + ex.Message + "StackTrace:\n" + ex.StackTrace)); throw; } label_61: binaryReader.Close(); return(mi); }
private static void SetEverydaySub(FreeModeItemEveryday.ScnearioType type, string fileName, AbstractFreeModeItem.GameMode gameMode, string fixingFlagText) { AFileBase afileBase; if (gameMode == AbstractFreeModeItem.GameMode.CM3D2) { afileBase = GameUty.FileSystemOld.FileOpen(fileName); } else { if (gameMode != AbstractFreeModeItem.GameMode.COM3D) { return; } afileBase = GameUty.FileSystem.FileOpen(fileName); } using (afileBase) { using (CsvParser csvParser = new CsvParser()) { bool condition = csvParser.Open(afileBase); NDebug.Assert(condition, fileName + "\nopen failed."); for (int i = 1; i < csvParser.max_cell_y; i++) { if (csvParser.IsCellToExistData(0, i)) { int cellAsInteger = csvParser.GetCellAsInteger(0, i); int num = 1; if (gameMode != AbstractFreeModeItem.GameMode.CM3D2 || type != FreeModeItemEveryday.ScnearioType.Nitijyou) { string name = csvParser.GetCellAsString(num++, i); string call_file_name = csvParser.GetCellAsString(num++, i); string check_flag_name = csvParser.GetCellAsString(num++, i); if (gameMode == AbstractFreeModeItem.GameMode.COM3D) { bool netorare = (csvParser.GetCellAsString(num++, i) == "○"); } string info_text = csvParser.GetCellAsString(num++, i); List <string> list = new List <string>(); for (int j = 0; j < 9; j++) { if (csvParser.IsCellToExistData(num, i)) { list.Add(csvParser.GetCellAsString(num, i)); } num++; } int subHerionID = csvParser.GetCellAsInteger(num++, i); while (csvParser.IsCellToExistData(num, 0)) { if (csvParser.GetCellAsString(num, i) == "○") { string cellAsString = csvParser.GetCellAsString(num, 0); //Personal.Data data = Personal.GetData(cellAsString); } num++; } if (GameMain.Instance.CharacterMgr.status.GetFlag(fixingFlagText + check_flag_name) == 0) { MyLog.LogMessage("SetEverydaySub.Flag" , check_flag_name , call_file_name , cellAsInteger , name , info_text ); GameMain.Instance.CharacterMgr.status.SetFlag(fixingFlagText + check_flag_name, 1); } } } } } } }
public static Material ReadMaterial(BinaryReader r, Material existmat) { string str1 = r.ReadString(); string str2 = r.ReadString(); string path = "DefMaterial/" + r.ReadString(); Material material = existmat; if (existmat == null) { Material original = Resources.Load(path, typeof(Material)) as Material; if ((UnityEngine.Object)original == (UnityEngine.Object)null) { NDebug.Assert("DefMaterialが見つかりません。" + path); } material = UnityEngine.Object.Instantiate <Material>(original); } else { material = existmat; NDebug.Assert(material.shader.name == str2, "マテリアル入れ替えエラー。違うシェーダーに入れようとしました。 " + str2 + " -> " + material.shader.name); } material.name = str1; int hashCode = material.name.GetHashCode(); // if (ImportCM.m_hashPriorityMaterials != null && ImportCM.m_hashPriorityMaterials.ContainsKey(hashCode)) // { // KeyValuePair<string, float> priorityMaterial = ImportCM.m_hashPriorityMaterials[hashCode]; // if (priorityMaterial.Key == material.name) // { // material.SetFloat("_SetManualRenderQueue", priorityMaterial.Value); // material.renderQueue = (int) priorityMaterial.Value; // } // } while (true) { string str3; string propertyName; string str4; do { str3 = r.ReadString(); if (!(str3 == "end")) { propertyName = r.ReadString(); if (str3 == "tex") { str4 = r.ReadString(); if (str4 == "null") { material.SetTexture(propertyName, (Texture)null); } else if (str4 == "tex2d") { string str5 = r.ReadString(); r.ReadString(); Texture2D texture = ImportCM.CreateTexture(str5 + ".tex"); texture.name = str5; texture.wrapMode = TextureWrapMode.Clamp; material.SetTexture(propertyName, (Texture)texture); // if (bodyskin != null) // bodyskin.listDEL.Add((UnityEngine.Object) texture); Vector2 offset; offset.x = r.ReadSingle(); offset.y = r.ReadSingle(); material.SetTextureOffset(propertyName, offset); Vector2 scale; scale.x = r.ReadSingle(); scale.y = r.ReadSingle(); material.SetTextureScale(propertyName, scale); } } else { goto label_36; } } else { goto label_43; } }while (!(str4 == "texRT")); r.ReadString(); r.ReadString(); continue; label_36: if (str3 == "col") { Color color; color.r = r.ReadSingle(); color.g = r.ReadSingle(); color.b = r.ReadSingle(); color.a = r.ReadSingle(); material.SetColor(propertyName, color); } else if (str3 == "vec") { Vector4 vector; vector.x = r.ReadSingle(); vector.y = r.ReadSingle(); vector.z = r.ReadSingle(); vector.w = r.ReadSingle(); material.SetVector(propertyName, vector); } else if (str3 == "f") { float num = r.ReadSingle(); material.SetFloat(propertyName, num); } else { Debug.LogError((object)("マテリアルが読み込めません。不正なマテリアルプロパティ型です " + str3)); } } label_43: return(material); }
void doExport() { // メニューファイル作成 menuFile.basePath = basePath; menuFile.outputPath = outputPath; menuFile.allowOverwrite = allowOverride; menuFile.allowSamename = allowSamename; // アイテム削除の反映 menuFile.items = new List <string>(); foreach (var key in delItems.Keys) { if (delItems[key]) { menuFile.items.Add(Params.GetDelMenu(key)); } } // ノード消去・表示の反映 menuFile.delNodes = new List <string>(); menuFile.showNodes = new List <string>(); foreach (var key in nodes.Keys) { switch (nodes[key]) { case 1: //消去 menuFile.delNodes.Add(key); break; case 2: //表示 menuFile.showNodes.Add(key); break; } } menuFile.maskItems = new List <string>(); foreach (var key in masks.Keys) { if (masks[key]) { menuFile.maskItems.Add(key); } } menuFile.materials = new List <string[]>(); menuFile.addItems = new List <string[]>(); if (filenameType == 1) { // プリフィクスからファイル名を設定 menuFile.filename = Params.GetFilename(Params.FileType.menu, filenamePrefix); menuFile.icons = Params.GetFilename(Params.FileType.icon, filenamePrefix); if (mateFiles != null) { foreach (var mate in mateFiles) { if (mate.export) { if (mateFiles.Count() == 1) { mate.filename = Params.GetFilename(Params.FileType.mate, filenamePrefix); } else { mate.filename = Params.GetFilename(Params.FileType.mate, filenamePrefix, mate.matno); } } menuFile.materials.Add(new string[] { mate.slotname, mate.matno.ToString(), mate.FilenameWithExtension }); } } foreach (var resource in menuFile.resources) { switch (resource[0]) { case MenuFile.ResourceMekureString: resource[1] = Params.GetFilename(Params.FileType.mekureMenu, filenamePrefix); break; case MenuFile.ResourceMekureBackString: resource[1] = Params.GetFilename(Params.FileType.mekureBackMenu, filenamePrefix); break; case MenuFile.ResourceZurashiString: resource[1] = Params.GetFilename(Params.FileType.zurashiMenu, filenamePrefix); break; } } if (addItems != null) { for (int i = 0; i < addItems.Count(); i++) { var model = addItems[i]; if (model.export) { if (addItems.Count() == 1) { model.filename = Params.GetFilename(Params.FileType.model, filenamePrefix); } else { model.filename = Params.GetFilename(Params.FileType.model, filenamePrefix, i); } } string[] item; switch (model.addItemType) { case ModelFile.AddItemType.attach: item = new string[] { model.FilenameWithExtension, model.slotname, MenuFile.AttachString, model.attachSlot, model.attachName }; break; case ModelFile.AddItemType.attachBone: item = new string[] { model.FilenameWithExtension, model.slotname, MenuFile.AttachBoneString, model.attachName }; break; default: item = new string[] { model.FilenameWithExtension, model.slotname }; break; } menuFile.addItems.Add(item); } } } else { // 指定したファイル名を使用する // マテリアル if (mateFiles != null) { foreach (var mate in mateFiles) { menuFile.materials.Add(new string[] { mate.category, mate.matno.ToString(), mate.FilenameWithExtension }); } } // additem(モデル) if (addItems != null) { foreach (var model in addItems) { menuFile.addItems.Add(new string[] { model.FilenameWithExtension, model.category }); } } } // menu書き出し menuFile.WriteMenu(); // アイコン if (menuFile.iconFile != null) { menuFile.iconFile.basePath = basePath; menuFile.iconFile.outputPath = menuFile.outputPath; menuFile.iconFile.category = menuFile.category; menuFile.iconFile.basename = menuFile.basename; menuFile.iconFile.filename = menuFile.icons; menuFile.iconFile.allowOverwrite = allowOverride; menuFile.iconFile.allowSamename = allowSamename; menuFile.iconFile.WriteTex(); } // マテリアル if (mateFiles != null) { foreach (var mate in mateFiles) { if (!mate.export) { continue; } mate.basePath = basePath; mate.outputPath = menuFile.outputPath; mate.name = mate.FilenameWithoutExtension; mate.allowOverwrite = allowOverride; mate.allowSamename = allowSamename; int count = 0; foreach (var key in mate.texs.Keys) { var tex = mate.texs[key]; if (!tex.export || tex.texFile == null || tex.type != TexParams.TexTypeTex2d) { continue; } tex.texFile.basePath = basePath; tex.texFile.outputPath = menuFile.outputPath; tex.texFile.allowOverwrite = allowOverride; tex.texFile.allowSamename = allowSamename; if (filenameType == 1) { if (mate.texs.Count() == 1) { tex.texFile.filename = Params.GetFilename(Params.FileType.tex, filenamePrefix + key); } else { tex.texFile.filename = Params.GetFilename(Params.FileType.tex, filenamePrefix + key, count); } } tex.filename = tex.texFile.FilenameWithoutExtension; tex.texFile.category = mate.category; tex.texFile.basename = mate.basename; tex.texFile.WriteTex(); count++; } if (mate.pmatFile != null && mate.pmatFile.export) { if (filenameType == 1) { mate.pmatFile.basePath = basePath; mate.pmatFile.outputPath = menuFile.outputPath; mate.pmatFile.allowOverwrite = allowOverride; mate.pmatFile.allowSamename = allowSamename; mate.pmatFile.filename = Params.GetFilename(Params.FileType.pmat, mate.FilenameWithoutExtension); } mate.pmatFile.name = mate.pmatFile.filename; mate.pmatFile.WritePmat(); } // mate書き出し mate.WriteMate(); } } // モデル if (addItems != null) { foreach (var model in addItems) { if (model.export) { // 対象のもののみ書き出し model.basePath = basePath; model.outputPath = menuFile.outputPath; model.allowOverwrite = allowOverride; model.allowSamename = allowSamename; model.WriteModel(); } } } NDebug.MessageBox("エクスポート", "エクスポート完了しました。"); }
public static bool InitMenuItemScript(SceneEdit.SMenuItem mi, string f_strMenuFileName, bool f_bMan, out string IconTex) { var fetchedField = AccessTools.DeclaredField(typeof(SceneEdit), "m_byItemFileBuffer"); var fetchedVal = fetchedField.GetValue(@this) as byte[]; IconTex = null; if (f_strMenuFileName.IndexOf("mod_") == 0) { string modPathFileName = Menu.GetModPathFileName(f_strMenuFileName); return(!string.IsNullOrEmpty(modPathFileName) && SceneEdit.InitModMenuItemScript(mi, modPathFileName)); } try { using (AFileBase afileBase = GameUty.FileOpen(f_strMenuFileName, null)) { NDebug.Assert(afileBase.IsValid(), "メニューファイルが存在しません。 :" + f_strMenuFileName); if (fetchedVal == null) { fetchedVal = new byte[System.Math.Max(500000, afileBase.GetSize())]; } else if (fetchedVal.Length < afileBase.GetSize()) { fetchedVal = new byte[afileBase.GetSize()]; } afileBase.Read(ref fetchedVal, afileBase.GetSize()); } } catch (Exception ex) { Main.logger.LogError(string.Concat(new string[] { "メニューファイルがが読み込めませんでした。 : ", f_strMenuFileName, " : ", ex.Message, " : StackTrace :\n", ex.StackTrace })); throw ex; } BinaryReader binaryReader = new BinaryReader(new MemoryStream(fetchedVal), Encoding.UTF8); string text = binaryReader.ReadString(); NDebug.Assert(text == "CM3D2_MENU", "ProcScriptBin 例外 : ヘッダーファイルが不正です。" + text); int num = binaryReader.ReadInt32(); string path = binaryReader.ReadString(); string text2 = binaryReader.ReadString(); string text3 = binaryReader.ReadString(); string text4 = binaryReader.ReadString(); long num2 = (long)binaryReader.ReadInt32(); int num3 = 0; string text5 = null; string text6 = string.Empty; string text7 = string.Empty; try { for (; ;) { int num4 = (int)binaryReader.ReadByte(); text7 = text6; text6 = string.Empty; if (num4 == 0) { break; } for (int i = 0; i < num4; i++) { text6 = text6 + "\"" + binaryReader.ReadString() + "\" "; } if (!(text6 == string.Empty)) { string stringCom = UTY.GetStringCom(text6); string[] stringList = UTY.GetStringList(text6); if (stringCom == "name") { string text8 = stringList[1]; string text9 = string.Empty; string arg = string.Empty; int j = 0; while (j < text8.Length && text8[j] != '\u3000' && text8[j] != ' ') { text9 += text8[j]; j++; } while (j < text8.Length) { arg += text8[j]; j++; } mi.m_strMenuName = text9; } else if (stringCom == "setumei") { mi.m_strInfo = stringList[1]; mi.m_strInfo = mi.m_strInfo.Replace("《改行》", "\n"); } else if (stringCom == "category") { string strCateName = stringList[1].ToLower(); mi.m_strCateName = strCateName; try { mi.m_mpn = (MPN)Enum.Parse(typeof(MPN), mi.m_strCateName); } catch { Main.logger.LogWarning("カテゴリがありません。" + mi.m_strCateName); mi.m_mpn = MPN.null_mpn; } } else if (stringCom == "color_set") { try { mi.m_eColorSetMPN = (MPN)Enum.Parse(typeof(MPN), stringList[1].ToLower()); } catch { Main.logger.LogWarning("カテゴリがありません。" + mi.m_strCateName); } if (stringList.Length >= 3) { mi.m_strMenuNameInColorSet = stringList[2].ToLower(); } } else if (stringCom == "tex" || stringCom == "テクスチャ変更") { MaidParts.PARTS_COLOR pcMultiColorID = MaidParts.PARTS_COLOR.NONE; if (stringList.Length == 6) { string text10 = stringList[5]; try { pcMultiColorID = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), text10.ToUpper()); } catch { NDebug.Assert("無限色IDがありません。" + text10, false); } mi.m_pcMultiColorID = pcMultiColorID; } } else if (stringCom == "icon" || stringCom == "icons") { text5 = stringList[1]; } else if (!(stringCom == "iconl")) { if (!(stringCom == "setstr")) { if (!(stringCom == "アイテムパラメータ")) { if (stringCom == "saveitem") { string text11 = stringList[1]; if (text11 == string.Empty) { Main.logger.LogError("err SaveItem \"" + text11); } if (text11 == null) { Main.logger.LogError("err SaveItem null=\"" + text11); } if (text11 != string.Empty) { } } else if (!(stringCom == "catno")) { if (stringCom == "additem") { num3++; } else if (stringCom == "unsetitem") { mi.m_boDelOnly = true; } else if (stringCom == "priority") { mi.m_fPriority = float.Parse(stringList[1]); } else if (stringCom == "メニューフォルダ" && stringList[1].ToLower() == "man") { mi.m_bMan = true; } } } } } } } } catch (Exception ex2) { Main.logger.LogError(string.Concat(new string[] { "Exception ", Path.GetFileName(path), " 現在処理中だった行 = ", text6, " 以前の行 = ", text7, " ", ex2.Message, "StackTrace:\n", ex2.StackTrace })); throw ex2; } if (text5 != null && text5 != string.Empty) { try { IconTex = text5; //mi.m_texIcon = ImportCM.CreateTexture(text5); } catch (Exception) { Main.logger.LogError("Error:"); } } binaryReader.Close(); return(true); }
public static bool InitMenuItemScript(SceneEdit.SMenuItem mi, string f_strMenuFileName, out string IconTex) { IconTex = null; if (f_strMenuFileName.IndexOf("mod_") == 0) { string modPathFileName = Menu.GetModPathFileName(f_strMenuFileName); return(!string.IsNullOrEmpty(modPathFileName) && SceneEdit.InitModMenuItemScript(mi, modPathFileName)); } try { if (MenuCache.ContainsKey(f_strMenuFileName)) { MenuStub tempStub = MenuCache[f_strMenuFileName]; if (tempStub.DateModified == File.GetLastWriteTimeUtc(FilesDictionary[f_strMenuFileName])) { if (tempStub.Name != null) { mi.m_strMenuName = tempStub.Name; } if (tempStub.Description != null) { mi.m_strInfo = tempStub.Description; } if (tempStub.Category != null) { mi.m_strCateName = tempStub.Category; mi.m_mpn = (MPN)Enum.Parse(typeof(MPN), tempStub.Category); } else { mi.m_mpn = MPN.null_mpn; } if (tempStub.ColorSetMPN != null) { mi.m_eColorSetMPN = (MPN)Enum.Parse(typeof(MPN), tempStub.ColorSetMPN); } if (tempStub.ColorSetMenu != null) { mi.m_strMenuNameInColorSet = tempStub.ColorSetMenu; } if (tempStub.MultiColorID == "null") { mi.m_pcMultiColorID = MaidParts.PARTS_COLOR.NONE; } else if (tempStub.MultiColorID != null) { mi.m_pcMultiColorID = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), tempStub.MultiColorID); } mi.m_boDelOnly = tempStub.DelMenu; mi.m_fPriority = tempStub.Priority; mi.m_bMan = tempStub.ManMenu; IconTex = tempStub.Icon; return(true); } else { Debug.Log($"A cache entry was found outdated. This should be automatically fixed and the cache reloaded."); } } if (FilesToRead[f_strMenuFileName] == null) { FilesToRead[f_strMenuFileName] = new MemoryStream(File.ReadAllBytes(FilesDictionary[f_strMenuFileName])); } } catch (Exception ex) { Debug.LogError(string.Concat(new string[] { "メニューファイルがが読み込めませんでした。 : ", f_strMenuFileName, " : ", ex.Message, " : StackTrace :\n", ex.StackTrace })); throw ex; } string text6 = string.Empty; string text7 = string.Empty; string path = ""; MenuStub cacheEntry = new MenuStub(); try { cacheEntry.DateModified = File.GetLastWriteTimeUtc(FilesDictionary[f_strMenuFileName]); BinaryReader binaryReader = new BinaryReader(FilesToRead[f_strMenuFileName], Encoding.UTF8); string text = binaryReader.ReadString(); NDebug.Assert(text == "CM3D2_MENU", "ProcScriptBin 例外 : ヘッダーファイルが不正です。" + text); binaryReader.ReadInt32(); path = binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadInt32(); string text5 = null; while (true) { int num4 = binaryReader.ReadByte(); text7 = text6; text6 = string.Empty; if (num4 == 0) { break; } for (int i = 0; i < num4; i++) { text6 = text6 + "\"" + binaryReader.ReadString() + "\" "; } if (!(text6 == string.Empty)) { string stringCom = UTY.GetStringCom(text6); string[] stringList = UTY.GetStringList(text6); if (stringCom == "name") { string text8 = stringList[1]; string text9 = string.Empty; string arg = string.Empty; int j = 0; while (j < text8.Length && text8[j] != '\u3000' && text8[j] != ' ') { text9 += text8[j]; j++; } while (j < text8.Length) { arg += text8[j]; j++; } mi.m_strMenuName = text9; cacheEntry.Name = mi.m_strMenuName; } else if (stringCom == "setumei") { mi.m_strInfo = stringList[1]; mi.m_strInfo = mi.m_strInfo.Replace("《改行》", "\n"); cacheEntry.Description = mi.m_strInfo; } else if (stringCom == "category") { string strCateName = stringList[1].ToLower(); mi.m_strCateName = strCateName; cacheEntry.Category = mi.m_strCateName; try { mi.m_mpn = (MPN)Enum.Parse(typeof(MPN), mi.m_strCateName); cacheEntry.Category = mi.m_mpn.ToString(); } catch { Debug.LogWarning("カテゴリがありません。" + mi.m_strCateName); mi.m_mpn = MPN.null_mpn; } } else if (stringCom == "color_set") { try { mi.m_eColorSetMPN = (MPN)Enum.Parse(typeof(MPN), stringList[1].ToLower()); cacheEntry.ColorSetMPN = mi.m_eColorSetMPN.ToString(); } catch { Debug.LogWarning("カテゴリがありません。" + mi.m_strCateName); } if (stringList.Length >= 3) { mi.m_strMenuNameInColorSet = stringList[2].ToLower(); cacheEntry.ColorSetMenu = mi.m_strMenuNameInColorSet; } } else if (stringCom == "tex" || stringCom == "テクスチャ変更") { MaidParts.PARTS_COLOR pcMultiColorID = MaidParts.PARTS_COLOR.NONE; cacheEntry.MultiColorID = "null"; if (stringList.Length == 6) { string text10 = stringList[5]; try { pcMultiColorID = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), text10.ToUpper()); } catch { NDebug.Assert("無限色IDがありません。" + text10, false); } mi.m_pcMultiColorID = pcMultiColorID; cacheEntry.MultiColorID = mi.m_pcMultiColorID.ToString(); } } else if (stringCom == "icon" || stringCom == "icons") { text5 = stringList[1]; } else if (!(stringCom == "iconl")) { if (!(stringCom == "setstr")) { if (!(stringCom == "アイテムパラメータ")) { if (stringCom == "saveitem") { string text11 = stringList[1]; if (text11 == string.Empty) { Debug.LogError("err SaveItem \"" + text11); } if (text11 == null) { Debug.LogError("err SaveItem null=\"" + text11); } } else if (!(stringCom == "catno")) { if (stringCom == "unsetitem") { mi.m_boDelOnly = true; cacheEntry.DelMenu = mi.m_boDelOnly; } else if (stringCom == "priority") { mi.m_fPriority = float.Parse(stringList[1]); cacheEntry.Priority = mi.m_fPriority; } else if (stringCom == "メニューフォルダ" && stringList[1].ToLower() == "man") { mi.m_bMan = true; cacheEntry.ManMenu = mi.m_bMan; } } } } } } } if (text5 != null && text5 != string.Empty) { try { IconTex = text5; cacheEntry.Icon = text5; //mi.m_texIcon = ImportCM.CreateTexture(text5); } catch (Exception) { Debug.LogError("Error:"); } } binaryReader.Close(); } catch (Exception ex2) { Debug.LogError(string.Concat(new string[] { "Exception ", Path.GetFileName(path), " 現在処理中だった行 = ", text6, " 以前の行 = ", text7, " ", ex2.Message, "StackTrace:\n", ex2.StackTrace })); throw ex2; } MenuCache[f_strMenuFileName] = cacheEntry; return(true); }