public static bool NoticeIfIllegalMaterials(Material[] array, bool showRemoveButton = true) { foreach (var mm in array) { if (ToolCommon.IsNotUnlitWFMaterial(mm)) { EditorGUILayout.HelpBox("Found Not-UnlitWF materials. Continue?\n(UnlitWF以外のマテリアルが紛れていますが大丈夫ですか?)", MessageType.Warning); if (showRemoveButton && GUILayout.Button("Remove other materials")) { return(true); } break; } } return(false); }
private void OnGUI() { var so = new SerializedObject(param); so.Update(); // タイトル EditorGUILayout.Space(); EditorGUILayout.LabelField("UnlitWF / Migration material", styleTitle); EditorGUILayout.Space(); EditorGUILayout.Space(); // メイン EditorGUILayout.LabelField("Migration materials", styleBigText); EditorGUILayout.HelpBox("古いバージョンのUnlitWFで設定されたmaterialsを最新版に変換します。", MessageType.Info); EditorGUILayout.Space(); // スクロール開始 scroll = EditorGUILayout.BeginScrollView(scroll); // マテリアルリスト EditorGUILayout.LabelField("materials", EditorStyles.boldLabel); EditorGUILayout.PropertyField(so.FindProperty("materials"), new GUIContent("list"), true); EditorGUILayout.Space(); // マテリアルに UnlitWF 以外のシェーダが紛れている場合には警告 bool removeOther = false; foreach (Material mm in param.materials) { if (ToolCommon.IsNotUnlitWFMaterial(mm)) { EditorGUILayout.HelpBox("Found Not-UnlitWF materials. Continue?\n(UnlitWF以外のマテリアルが紛れていますが大丈夫ですか?)", MessageType.Warning); if (GUILayout.Button("Remove other materials")) { removeOther = true; } break; } } EditorGUILayout.Space(); so.ApplyModifiedPropertiesWithoutUndo(); so.SetIsDifferentCacheDirty(); // UnlitWF 以外のマテリアルを除去 if (removeOther) { var newlist = new List <Material>(); newlist.AddRange(param.materials); newlist.RemoveAll(mm => !ToolCommon.IsUnlitWFMaterial(mm)); param.materials = newlist.ToArray(); } if (GUILayout.Button("Convert")) { if (new WFMaterialEditUtility().RenameOldNameProperties(param)) { // ShaderGUI側のマテリアルキャッシュをリセット ShaderCustomEditor.ResetOldMaterialTable(); // 変更したマテリアルを保存 AssetDatabase.SaveAssets(); } } EditorGUILayout.Space(); // スクロール終了 EditorGUILayout.EndScrollView(); }
private void OnGUI() { var so = new SerializedObject(param); so.Update(); // タイトル EditorGUILayout.Space(); EditorGUILayout.LabelField("UnlitWF / Copy material property", styleTitle); EditorGUILayout.Space(); EditorGUILayout.Space(); // メイン EditorGUILayout.LabelField("Copy properties", styleBigText); EditorGUILayout.HelpBox("source material の設定値を destination materials にコピーします。", MessageType.Info); EditorGUILayout.Space(); // スクロール開始 scroll = EditorGUILayout.BeginScrollView(scroll); // マテリアルリスト EditorGUILayout.LabelField("destination materials", EditorStyles.boldLabel); EditorGUILayout.PropertyField(so.FindProperty("materialDestination"), new GUIContent("list"), true); EditorGUILayout.Space(); // マテリアルに UnlitWF 以外のシェーダが紛れている場合には警告 bool removeOther = false; foreach (Material mm in param.materialDestination) { if (ToolCommon.IsNotUnlitWFMaterial(mm)) { EditorGUILayout.HelpBox("Found Not-UnlitWF materials. Continue?\n(UnlitWF以外のマテリアルが紛れていますが大丈夫ですか?)", MessageType.Warning); if (GUILayout.Button("Remove other materials")) { removeOther = true; } break; } } EditorGUILayout.Space(); EditorGUILayout.LabelField("source materials", EditorStyles.boldLabel); EditorGUILayout.PropertyField(so.FindProperty("materialSource"), new GUIContent("material"), true); EditorGUILayout.Space(); if (ToolCommon.IsNotUnlitWFMaterial(param.materialSource)) { EditorGUILayout.HelpBox("Found Not-UnlitWF materials. Continue?\n(UnlitWF以外のマテリアルが紛れていますが大丈夫ですか?)", MessageType.Warning); EditorGUILayout.Space(); } so.ApplyModifiedPropertiesWithoutUndo(); so.SetIsDifferentCacheDirty(); // 対象 EditorGUILayout.LabelField("copy target functions", EditorStyles.boldLabel); var updatedFunctions = new List <string>(); foreach (var func in WFShaderDictionary.ShaderFuncList) { if (func.Contains(param.materialSource)) { bool value = param.functions.Contains(func.Label); if (GUILayout.Toggle(value, string.Format("[{0}] {1}", func.Label, func.Name))) { updatedFunctions.Add(func.Label); } } } if (!updatedFunctions.SequenceEqual(param.functions)) { param.functions = updatedFunctions.ToArray(); } EditorGUILayout.Space(); // UnlitWF 以外のマテリアルを除去 if (removeOther) { var newlist = new List <Material>(); newlist.AddRange(param.materialDestination); newlist.RemoveAll(mm => !ToolCommon.IsUnlitWFMaterial(mm)); param.materialDestination = newlist.ToArray(); } using (new EditorGUI.DisabledGroupScope(param.functions.Length == 0)) { if (GUILayout.Button("Copy Values")) { new WFMaterialEditUtility().CopyProperties(param); } } EditorGUILayout.Space(); // スクロール終了 EditorGUILayout.EndScrollView(); }
private void OnGUI() { var so = new SerializedObject(param); so.Update(); SerializedProperty prop; // タイトル EditorGUILayout.Space(); EditorGUILayout.LabelField("UnlitWF / Reset material property", styleTitle); EditorGUILayout.Space(); EditorGUILayout.Space(); // メイン EditorGUILayout.LabelField("Reset properties", styleBigText); EditorGUILayout.HelpBox("materialsの設定値を初期化します。", MessageType.Info); EditorGUILayout.Space(); // スクロール開始 scroll = EditorGUILayout.BeginScrollView(scroll); // マテリアルリスト EditorGUILayout.LabelField("materials", EditorStyles.boldLabel); EditorGUILayout.PropertyField(so.FindProperty("materials"), new GUIContent("list"), true); EditorGUILayout.Space(); // マテリアルに UnlitWF 以外のシェーダが紛れている場合には警告 bool removeOther = false; foreach (Material mm in param.materials) { if (ToolCommon.IsNotUnlitWFMaterial(mm)) { EditorGUILayout.HelpBox("Found Not-UnlitWF materials. Continue?\n(UnlitWF以外のマテリアルが紛れていますが大丈夫ですか?)", MessageType.Warning); if (GUILayout.Button("Remove other materials")) { removeOther = true; } break; } } EditorGUILayout.Space(); // 対象(種類から) EditorGUILayout.LabelField("Reset by Type", EditorStyles.boldLabel); prop = so.FindProperty("resetColor"); prop.boolValue = GUILayout.Toggle(prop.boolValue, "Color (色) をデフォルトに戻す"); prop = so.FindProperty("resetTexture"); prop.boolValue = GUILayout.Toggle(prop.boolValue, "Texture (テクスチャ) をデフォルトに戻す"); prop = so.FindProperty("resetFloat"); prop.boolValue = GUILayout.Toggle(prop.boolValue, "Float (数値) をデフォルトに戻す"); EditorGUILayout.Space(); // 対象(機能から) EditorGUILayout.LabelField("Reset by Function", EditorStyles.boldLabel); prop = so.FindProperty("resetColorAlpha"); prop.boolValue = GUILayout.Toggle(prop.boolValue, "Color (色) の Alpha を 1.0 にする"); prop = so.FindProperty("resetLit"); prop.boolValue = GUILayout.Toggle(prop.boolValue, "Lit & Lit Advance の設定をデフォルトに戻す"); EditorGUILayout.Space(); // オプション EditorGUILayout.LabelField("options", EditorStyles.boldLabel); prop = so.FindProperty("resetUnused"); prop.boolValue = GUILayout.Toggle(prop.boolValue, "UnUsed Properties (未使用の値) も一緒にクリアする"); prop = so.FindProperty("resetKeywords"); prop.boolValue = GUILayout.Toggle(prop.boolValue, "ShaderKeywords (Shaderキーワード) も一緒にクリアする"); EditorGUILayout.Space(); so.ApplyModifiedPropertiesWithoutUndo(); so.SetIsDifferentCacheDirty(); // UnlitWF 以外のマテリアルを除去 if (removeOther) { var newlist = new List <Material>(); newlist.AddRange(param.materials); newlist.RemoveAll(mm => !ToolCommon.IsUnlitWFMaterial(mm)); param.materials = newlist.ToArray(); } if (GUILayout.Button("Reset Values")) { new WFMaterialEditUtility().ResetProperties(param); } EditorGUILayout.Space(); // スクロール終了 EditorGUILayout.EndScrollView(); }