public void drag(int id) { GUILayoutUtility.BeginGroup("str"); scrollPos = EditorGUILayout.BeginScrollView(scrollPos); int deleteIndex = -1; for (int i = 0; i < fsm.totalVariable.Count; i++) { BeginHorizontal(); fsm.totalVariable[i].Name = CreateStringField(fsm.totalVariable[i].Name); DoButton("Delete", () => { deleteIndex = i; }); EndHorizontal(); fsm.totalVariable[i].variableValue = GetTypeGUI(fsm.totalVariable[i].variableValue, fsm.totalVariable[i].variableType, fsm.totalVariable[i].variableType.Name, null); EditorUtility.SetDirty(fsm.totalVariable[i]); } if (deleteIndex != -1) { if (fsm.template != null) { fsm.template.totalVariable.RemoveAt(deleteIndex); DestroyImmediate(fsm.totalVariable[deleteIndex], true); } else { DestroyImmediate(fsm.totalVariable[deleteIndex]); } fsm.RemoveVar(deleteIndex); } EditorGUILayout.EndScrollView(); GUILayoutUtility.EndGroup("str"); GUI.DragWindow(); //EditorGUILayout.TextField( GraphTitle ); }
//public bool CheckData() { // return true; //} // TODO 複数のマテリアルのmateファイルが同一の場合 // 設定、textureが同じであるかを判定して、同一にしてよいかを判定⇒変更前のファイルが同一であれば一緒。 // 複数のスロットで同一のmodelファイルを指定している場合、 // 現状は、他方へリンクを張り、同一modelとして出力 // シェーダが異なる場合は別modelとして出力する必要がある(TODO) // TODO 汚すぎるため、要リファクタ public void Show() { if (trgtMenu == null) { return; } scrollViewPosition = GUILayout.BeginScrollView(scrollViewPosition, optScrlWidth, optScrlHeight); GUILayout.BeginVertical(); GUILayout.Space(uiParams.unitHeight); Color txtColr = uiParams.textStyle.normal.textColor; Color errColr = Color.red; try { GUILayout.BeginHorizontal(); GUILayout.Label("メニュー", uiParams.lStyle, optLabelWidth); string before = trgtMenu.editfile; if (trgtMenu.editfileExist) { uiParams.textStyle.normal.textColor = errColr; } trgtMenu.editfile = GUILayout.TextField(trgtMenu.editfile, uiParams.textStyle); if (trgtMenu.editfileExist) { uiParams.textStyle.normal.textColor = txtColr; } ; nameChanged |= (trgtMenu.editfile != before); GUILayout.Label(FileConst.EXT_MENU, uiParams.lStyleS, optExtLabelWidth); bool src = nameInterlocked; nameInterlocked = GUILayout.Toggle(nameInterlocked, "名前連動", uiParams.tStyleS, uiParams.optSLabelWidth); if (nameInterlocked && src != nameInterlocked) { nameChanged = true; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("内部パス", uiParams.lStyle, optLabelWidth); trgtMenu.txtpath = GUILayout.TextField(trgtMenu.txtpath, uiParams.textStyle); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("優先度", uiParams.lStyle, optLabelWidth); var editedPriority = GUILayout.TextField(trgtMenu.priority, 10, uiParams.textStyle, modalHalfWidth); if (trgtMenu.priority != editedPriority) { // float? int v; if (int.TryParse(editedPriority, out v)) { if (v >= 0) { trgtMenu.priority = v.ToString(); } } } GUILayout.Space(indentWidth); GUILayout.Label("カテゴリ", uiParams.lStyleS); GUILayout.Label(trgtMenu.category, uiParams.lStyleS); if (GUILayout.Button("↑ パス自動設定", uiParams.bStyle)) { trgtMenu.txtpath = settings.txtPrefixTex + trgtMenu.editfile; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("アイコン", uiParams.lStyle, optLabelWidth); GUI.enabled = !nameInterlocked; if (nameInterlocked && nameChanged) { if (!trgtMenu.editfile.ToLower().EndsWith(settings.iconSuffix, StringComparison.Ordinal)) { trgtMenu.editicon = trgtMenu.editfile + settings.iconSuffix; } else { trgtMenu.editicon = trgtMenu.editfile; } } if (trgtMenu.editfileExist) { uiParams.textStyle.normal.textColor = errColr; } trgtMenu.editicon = GUILayout.TextField(trgtMenu.editicon, uiParams.textStyle); if (trgtMenu.editfileExist) { uiParams.textStyle.normal.textColor = txtColr; } GUI.enabled = true; GUILayout.Label(FileConst.EXT_TEXTURE, uiParams.lStyleS, optExtLabelWidth); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("名前", uiParams.lStyle, optLabelWidth); trgtMenu.name = GUILayout.TextField(trgtMenu.name, uiParams.textStyle); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(optTwoLineHeight); GUILayout.Label("説明", uiParams.lStyle, optLabelWidth); trgtMenu.desc = GUILayout.TextArea(trgtMenu.desc, uiParams.textAreaStyleS, optTwoLineHeight); GUILayout.EndHorizontal(); const string gname = "material"; GUILayoutUtility.BeginGroup(gname); try { foreach (var pair in trgtMenu.slotMaterials) { GUILayout.Label("マテリアル情報 (" + pair.Key + ")", uiParams.lStyle); foreach (var trgtMat in pair.Value.materials) { if (trgtMat == null) { continue; } GUILayout.BeginHorizontal(); try { GUILayout.Space(indentWidth); if (trgtMat.onlyModel) { uiParams.lStyleS.normal.textColor = Color.cyan; } GUILayout.Label("マテリアル" + trgtMat.matNo, uiParams.lStyleS, optSubLabelWidth); if (trgtMat.onlyModel) { uiParams.lStyleS.normal.textColor = txtColr; } // マテリアルファイル名 if (trgtMat.onlyModel) { GUILayout.Label("(.mateファイル無し)", uiParams.lStyleS); } else { if (trgtMat.editfileExist) { uiParams.textStyle.normal.textColor = errColr; } GUI.enabled = !nameInterlocked; if (nameInterlocked && nameChanged) { trgtMat.editfile = trgtMenu.editfile + trgtMat.matNo; } trgtMat.editfile = GUILayout.TextField(trgtMat.editfile, uiParams.textStyle); if (trgtMat.editfileExist) { uiParams.textStyle.normal.textColor = txtColr; } GUI.enabled = true; GUILayout.Label(FileConst.EXT_MATERIAL, uiParams.lStyleS, optExtLabelWidth); if (trgtMat.needPmat && trgtMat.needPmatChange) { GUILayout.Label("|" + FileConst.EXT_PMAT, uiParams.lStyleS, optExtLabelWidth); } } // マテリアル名 if (!trgtMat.needPmat) { // 名前は任意 trgtMat.editname = GUILayout.TextField(trgtMat.editname, uiParams.textStyle); } else { if (trgtMat.needPmatChange) { // pmat出力する場合 trgtMat.editname = trgtMat.editfile; trgtMat.editname = GUILayout.TextField(trgtMat.editname, uiParams.textStyle); } else { GUI.enabled = false; trgtMat.editname = GUILayout.TextField(trgtMat.editname, uiParams.textStyle); GUI.enabled = true; } } } catch (Exception e) { LogUtil.Debug("failed to display material name:", trgtMat.editname, e); } finally { GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); try { GUILayout.Space(indentWidth * 2); string blabel = trgtMat.uiTexViewed? "-": "+"; if (GUILayout.Button(blabel, uiParams.optBtnWidth)) { trgtMat.uiTexViewed = !trgtMat.uiTexViewed; } string shaderName = trgtMat.ShaderNameOrDefault("不明"); GUILayout.Label("シェーダ : " + shaderName, uiParams.lStyleS, optShaderWidth); GUILayout.Space(indentWidth); uiParams.lStyleS.normal.textColor = changedColor; GUILayout.Label(trgtMat.shaderChanged? "変更有":"", uiParams.lStyleS); uiParams.lStyleS.normal.textColor = txtColr; // TODO pmat出力の有無指定 if (!trgtMat.needPmat) { GUILayout.Label("pmat不要(透過無)", uiParams.lStyleS, optLabelWidth); } else { if (trgtMat.needPmatChange) { GUI.enabled = false; trgtMat.pmatExport = GUILayout.Toggle(trgtMat.pmatExport, "pmat出力", uiParams.lStyleS, optLabelWidth); GUI.enabled = true; } else { GUILayout.Label("既存pmat利用", uiParams.lStyleS, optLabelWidth); } } } catch (Exception e) { LogUtil.Debug("failed to display shader info:", trgtMat.editname, e); } finally { GUILayout.EndHorizontal(); } if (trgtMat.uiTexViewed) { GUILayout.BeginVertical(); try { // 現在のマテリアルからテクスチャ取得 Material mat = trgtMat.editedMat.material; //foreach (var propName in trgtMat.editedMat.type.texPropNames) { foreach (var texProp in trgtMat.editedMat.type.texProps) { TargetTexture trgtTex; if (!trgtMat.texDic.TryGetValue(texProp.key, out trgtTex)) { continue; } if (trgtTex.tex == null) { continue; } GUILayout.BeginHorizontal(optSubItemHeight); GUILayout.Space(indentWidth * 4); string propName = texProp.keyName; GUILayout.Label(propName, uiParams.lStyleS, optPropNameWidth); if (trgtTex.needOutput) { GUI.enabled = !nameInterlocked; if (nameInterlocked && nameChanged) { trgtTex.editname = trgtMat.editfile + FileConst.GetTexSuffix(propName); } } else { GUI.enabled = false; } if (!trgtMat.onlyModel) { if (trgtTex.editnameExist) { uiParams.textStyle.normal.textColor = errColr; } trgtTex.editname = GUILayout.TextField(trgtTex.editname, uiParams.textStyle); if (trgtTex.editnameExist) { uiParams.textStyle.normal.textColor = txtColr; } GUI.enabled = true; if (trgtTex.colorChanged) { uiParams.lStyleS.normal.textColor = changedColor; GUILayout.Label("色変更", uiParams.lStyleS, optExtLabelWidth); uiParams.lStyleS.normal.textColor = txtColr; } else { if (trgtTex.fileChanged) { uiParams.lStyleS.normal.textColor = changedColor; GUILayout.Label("変更有", uiParams.lStyleS, optExtLabelWidth); uiParams.lStyleS.normal.textColor = txtColr; } } // texは色変更があった場合にのみ出力 } else { // modelファイルのマテリアルを使用している場合 if (trgtTex.editnameExist) { uiParams.lStyle.normal.textColor = errColr; } GUILayout.Label(trgtTex.editname, uiParams.lStyleS); if (trgtTex.editnameExist) { uiParams.lStyle.normal.textColor = txtColr; } } GUI.enabled = true; GUILayout.EndHorizontal(); } } catch (Exception e) { LogUtil.Debug("failed to display tex info.", e); } finally { GUI.enabled = true; GUILayout.EndVertical(); } } else if (nameInterlocked && nameChanged) { // 非表示でもデータは更新 //foreach (var propName in trgtMat.editedMat.type1.texPropNames) { foreach (var texProp in trgtMat.editedMat.type.texProps) { TargetTexture trgtTex; if (!trgtMat.texDic.TryGetValue(texProp.key, out trgtTex)) { continue; } if (trgtTex.tex == null) { continue; } if (trgtTex.needOutput) { trgtTex.editname = trgtMat.editfile + FileConst.GetTexSuffix(texProp.keyName); } } } // GUILayout.EndHorizontal(); } } } catch (Exception e) { LogUtil.Error("failed to display material", e); } finally { GUILayoutUtility.EndGroup(gname); } if (trgtMenu.addItems.Any()) { const string gname2 = "item"; GUILayoutUtility.BeginGroup(gname2); GUILayout.Label("additem (model)", uiParams.lStyle); foreach (var item in trgtMenu.addItems) { try { if (item.HasSlot()) { GUILayout.BeginHorizontal(); GUILayout.Space(indentWidth); GUILayout.Label(item.slot, uiParams.lStyleS, optLabelWidth); if (item.editnameExist) { uiParams.textStyle.normal.textColor = errColr; uiParams.lStyleS.normal.textColor = errColr; } // 同一ファイル名のモデルを参照するリンクがあった場合は変更できないラベルとする if (item.HasLink()) { GUILayout.Label(item.link.EditFileName(), uiParams.lStyleS); } else if (!item.needUpdate) { GUILayout.Label(item.EditFileName(), uiParams.lStyleS); } else { GUI.enabled = !nameInterlocked; if (nameInterlocked && nameChanged) { var suffix = FileConst.GetModelSuffix(item.slot); if (trgtMenu.editfile.Contains(suffix)) { item.editname = trgtMenu.editfile; } else { item.editname = trgtMenu.editfile + suffix; } } item.editname = GUILayout.TextField(item.editname, uiParams.textStyle); GUI.enabled = true; GUILayout.Label(FileConst.EXT_MODEL, uiParams.lStyleS, optExtLabelWidth); } if (item.editnameExist) { uiParams.textStyle.normal.textColor = txtColr; uiParams.lStyleS.normal.textColor = txtColr; } GUILayout.EndHorizontal(); if (item.info.Length >= 3) { GUILayout.BeginHorizontal(); GUILayout.Space(indentWidth); GUILayout.Label("追加情報", uiParams.lStyleS, optLabelWidth); var sb = new StringBuilder(); for (int i = 2; i < item.info.Length; i++) { sb.Append(item.info[i]).Append(", "); } GUILayout.Label(sb.ToString(), uiParams.lStyleS); GUILayout.EndHorizontal(); } } } catch (Exception e) { LogUtil.Debug("failed to display item info:", item.slot, e); } finally { GUILayoutUtility.EndGroup(gname2); } } } if (trgtMenu.resources.Any()) { const string gname3 = "resource"; GUILayoutUtility.BeginGroup(gname3); try { GUILayout.Label("リソース参照", uiParams.lStyle); foreach (var resRef in trgtMenu.resources) { GUILayout.BeginHorizontal(); GUILayout.Space(indentWidth); GUILayout.Label(resRef.key, uiParams.lStyleS, optSubLabelWidth); if (nameInterlocked && nameChanged) { resRef.editname = trgtMenu.editfile + resRef.suffix; } GUI.enabled = !nameInterlocked; if (resRef.editfileExist) { uiParams.textStyle.normal.textColor = errColr; } resRef.editname = GUILayout.TextField(resRef.editname, uiParams.textStyle); if (resRef.editfileExist) { uiParams.textStyle.normal.textColor = txtColr; } GUI.enabled = true; GUILayout.Label(FileConst.EXT_MENU, uiParams.lStyleS, optExtLabelWidth); GUILayout.EndHorizontal(); } } catch (Exception e) { LogUtil.Debug("failed to display resource info.", e); } finally { GUILayoutUtility.EndGroup(gname3); } } nameChanged = false; } finally { GUILayout.EndVertical(); GUILayout.EndScrollView(); } GUILayout.BeginHorizontal(); GUILayout.Space(uiParams.marginL); ignoreExist = !GUILayout.Toggle(!ignoreExist, "登録済確認", uiParams.tStyleS, uiParams.optSLabelWidth); if (GUILayout.Button("保存", uiParams.bStyle)) { if (IsWritable(trgtMenu, ignoreExist)) { if (SaveFiles(trgtMenu)) { var logmsg = "エクスポートが完了しました。出力先=" + fileUtil.GetACCDirectory(trgtMenu.editfile); NUty.WinMessageBox(NUty.GetWindowHandle(), logmsg, "情報", NUty.MSGBOX.MB_OK); //showDialog = false; } } else { const string logmsg = "出力ファイルが登録済みか重複が存在するため、保存処理を行いませんでした。"; NUty.WinMessageBox(NUty.GetWindowHandle(), logmsg, "エラー", NUty.MSGBOX.MB_OK); } } if (GUILayout.Button("閉じる", uiParams.bStyle)) { showDialog = false; } GUILayout.Space(uiParams.marginL); GUILayout.EndHorizontal(); }