Пример #1
0
 private static string SplitAndTranslate(string before)
 {
     if (WFCommonUtility.FormatDispName(before, out var label, out var text, out var _))
     {
         // text がラベルとテキストに分割できるならば
         return("[" + label + "] " + Translate(label, text));
     }
Пример #2
0
        public static string GetDisplayName(string text)
        {
            text = text ?? "";
            var current = GetDict();

            if (current == null)
            {
                return(text); // 無いなら変換しない
            }
            string ret;

            // text がラベルとテキストに分割できるならば
            if (WFCommonUtility.FormatDispName(text, out string label, out string name2, out ret))
            {
                // ラベルとテキストが両方とも一致するものを最初に検索する
                ret = current.Where(t => t.ContainsTag(label) && t.Before == name2).Select(t => t.After).FirstOrDefault();
                if (ret != null)
                {
                    return("[" + label + "] " + ret);
                }
                // ラベルなしでテキストが一致するものを検索する
                ret = current.Where(t => t.HasNoTag() && t.Before == name2).Select(t => t.After).FirstOrDefault();
                if (ret != null)
                {
                    return("[" + label + "] " + ret);
                }
                //// ラベル問わずテキストが一致するものを検索する
                //ret = current.Where(t => t.Before == name2).Select(t => t.After).FirstOrDefault();
                //if (ret != null) {
                //    return "[" + label + "] " + ret;
                //}
            }
Пример #3
0
        public static string GetDisplayName(string text)
        {
            text = text ?? "";
            Dictionary <string, string> current = GetDict();

            if (current != null)
            {
                string ret;
                if (current.TryGetValue(text, out ret))
                {
                    return(ret);
                }
                string label, name2;
                if (WFCommonUtility.FormatDispName(text, out label, out name2, out ret))
                {
                    if (current.TryGetValue(name2, out ret))
                    {
                        return("[" + label + "] " + ret);
                    }
                }
            }
            return(text);
        }
Пример #4
0
        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");
            }
        }