private void OnGuiSub_ShaderProperty(MaterialEditor materialEditor, MaterialProperty[] properties, MaterialProperty prop) { // GUIContent 作成 GUIContent guiContent = WFI18N.GetGUIContent(prop.displayName); // テクスチャとカラーを1行で表示する if (COMBI_COLOR_TEX.ContainsKey(prop.name)) { MaterialProperty another = FindProperty(COMBI_COLOR_TEX[prop.name], properties, false); if (another != null) { DoSingleLineTextureProperty(materialEditor, guiContent, prop, another); return; } } else if (COMBI_COLOR_TEX.ContainsValue(prop.name)) { return; // 相方の側は何もしない } // MinMaxSlider if (COMBI_MIN_MAX.ContainsKey(prop.name)) { MaterialProperty another = FindProperty(COMBI_MIN_MAX[prop.name], properties, false); if (another != null) { DoMinMaxProperty(materialEditor, guiContent, prop, another); return; } } else if (COMBI_MIN_MAX.ContainsValue(prop.name)) { return; // 相方の側は何もしない } materialEditor.ShaderProperty(prop, guiContent); }
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties) { materialEditor.SetDefaultGUIWidths(); Material mat = materialEditor.target as Material; if (mat != null) { // CurrentShader OnGuiSub_ShowCurrentShaderName(materialEditor, mat); // マイグレーションHelpBox OnGUISub_MigrationHelpBox(materialEditor); // Batching Static対策HelpBox OnGUISub_BatchingStaticHelpBox(materialEditor); } // 現在無効なラベルを保持するリスト var disable = new HashSet <string>(); // プロパティを順に描画 foreach (var prop in properties) { // ラベル付き displayName を、ラベルと名称に分割 string label, name, disp; WFCommonUtility.FormatDispName(prop.displayName, out label, out name, out disp); // ラベルが指定されていてdisableに入っているならばスキップ(ただしenable以外) if (label != null && disable.Contains(label) && !WFCommonUtility.IsEnableToggle(label, name)) { continue; } // _TS_1stColorの直前にボタンを追加する if (prop.name == "_TS_1stColor") { Rect position = EditorGUILayout.GetControlRect(true, 24); Rect fieldpos = EditorGUI.PrefixLabel(position, WFI18N.GetGUIContent("[SH] Shade Color Suggest", "ベース色をもとに1影2影色を設定します")); fieldpos.height = 20; if (GUI.Button(fieldpos, "APPLY")) { SuggestShadowColor(WFCommonUtility.AsMaterials(materialEditor.targets)); } } // HideInInspectorをこのタイミングで除外するとFix*Drawerが動作しないのでそのまま通す // 非表示はFix*Drawerが担当 // Fix*Drawerと一緒にHideInInspectorを付けておけば、このcsが無い環境でも非表示のまま変わらないはず // if ((prop.flags & MaterialProperty.PropFlags.HideInInspector) != MaterialProperty.PropFlags.None) { // continue; // } // 更新監視 EditorGUI.BeginChangeCheck(); // 描画 OnGuiSub_ShaderProperty(materialEditor, properties, prop); // 更新監視 if (EditorGUI.EndChangeCheck()) { foreach (var setter in DEF_VALUE_SETTER) { setter(prop, properties); } } // ラベルが指定されていてenableならば有効無効をリストに追加 // このタイミングで確認する理由は、ShaderProperty内でFix*Drawerが動作するため if (WFCommonUtility.IsEnableToggle(label, name)) { if ((int)prop.floatValue == 0) { disable.Add(label); } else { disable.Remove(label); } } } DrawShurikenStyleHeader(EditorGUILayout.GetControlRect(false, 32), "Advanced Options", null); materialEditor.RenderQueueField(); materialEditor.EnableInstancingField(); //materialEditor.DoubleSidedGIField(); WFI18N.LangMode = (EditorLanguage)EditorGUILayout.EnumPopup("Editor language", WFI18N.LangMode); // 不要なシェーダキーワードは削除 foreach (object t in materialEditor.targets) { Material mm = t as Material; if (mm != null) { foreach (var key in DELETE_KEYWORD) { if (mm.IsKeywordEnabled(key)) { mm.DisableKeyword(key); } } } } }
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties) { materialEditor.SetDefaultGUIWidths(); Material mat = materialEditor.target as Material; if (mat != null) { var rect = EditorGUILayout.GetControlRect(); rect.y += 2; GUI.Label(rect, "Current Shader", EditorStyles.boldLabel); GUILayout.Label(new Regex(@".*/").Replace(mat.shader.name, "")); } // 現在無効なラベルを保持するリスト var disable = new List <string>(); // プロパティを順に描画 foreach (var prop in properties) { // ラベル付き displayName を、ラベルと名称に分割 string label, name, disp; WFCommonUtility.FormatDispName(prop.displayName, out label, out name, out disp); // ラベルが指定されていてdisableに入っているならばスキップ(ただしenable以外) if (label != null && disable.Contains(label) && !WFCommonUtility.IsEnableToggle(label, name)) { continue; } // _TS_1stColorの直前にボタンを追加する if (prop.name == "_TS_1stColor") { Rect position = EditorGUILayout.GetControlRect(true, 24); Rect fieldpos = EditorGUI.PrefixLabel(position, WFI18N.GetGUIContent("[SH] Shade Color Suggest", "ベース色をもとに1影2影色を設定します")); fieldpos.height = 20; if (GUI.Button(fieldpos, "APPLY")) { SuggestShadowColor(materialEditor.targets); } } // HideInInspectorをこのタイミングで除外するとFix*Drawerが動作しないのでそのまま通す // 非表示はFix*Drawerが担当 // Fix*Drawerと一緒にHideInInspectorを付けておけば、このcsが無い環境でも非表示のまま変わらないはず // if ((prop.flags & MaterialProperty.PropFlags.HideInInspector) != MaterialProperty.PropFlags.None) { // continue; // } // 描画 GUIContent guiContent = WFI18N.GetGUIContent(prop.displayName); if (COLOR_TEX_COBINATION.ContainsKey(prop.name)) { MaterialProperty propTex = FindProperty(COLOR_TEX_COBINATION[prop.name], properties, false); if (propTex != null) { materialEditor.TexturePropertySingleLine(guiContent, propTex, prop); } else { materialEditor.ShaderProperty(prop, guiContent); } } else if (COLOR_TEX_COBINATION.ContainsValue(prop.name)) { // nop } else { materialEditor.ShaderProperty(prop, guiContent); } // ラベルが指定されていてenableならば有効無効をリストに追加 // このタイミングで確認する理由は、ShaderProperty内でFix*Drawerが動作するため if (WFCommonUtility.IsEnableToggle(label, name)) { if ((int)prop.floatValue == 0) { disable.Add(label); } else { disable.Remove(label); } } } DrawShurikenStyleHeader(EditorGUILayout.GetControlRect(false, 32), "Advanced Options", null); materialEditor.RenderQueueField(); materialEditor.EnableInstancingField(); //materialEditor.DoubleSidedGIField(); WFI18N.LangMode = (EditorLanguage)EditorGUILayout.EnumPopup("Editor language", WFI18N.LangMode); // DebugView の NONE ならばキーワードを削除する foreach (object t in materialEditor.targets) { Material mm = t as Material; if (mm == null || Array.IndexOf(mm.shaderKeywords, "_WF_DEBUGVIEW_NONE") < 0) { continue; } mm.DisableKeyword("_WF_DEBUGVIEW_NONE"); } }