Esempio n. 1
0
        public void Show()
        {
            GUILayout.BeginVertical(inboxStyle);
            try {
                string matName = (expand? "- " : "+ ") + material.name;
                if (GUILayout.Button(matName, uiParams.lStyleC))
                {
                    expand = !expand;
                }
                if (!expand)
                {
                    return;
                }

                foreach (ACCTexture editTex in edited)
                {
                    bool bTargetElement = (matNo == editTarget.matNo && editTex.propKey == editTarget.propKey);

                    GUILayout.BeginHorizontal();
                    try {
                        // エディット用スライダーの開閉
                        if (!textureModifier.IsValidTarget(holder.currentMaid, holder.currentSlot.Name, material, editTex.propName))
                        {
                            // 参照先が Texture2D が取れなかった (例 : RenderTexture ) 場合は何もしない
                            var tmp = GUI.enabled;
                            GUI.enabled = false;
                            GUILayout.Button("+変更", uiParams.bStyle, buttonLWidth);
                            GUI.enabled = tmp;
                        }
                        else if (bTargetElement)
                        {
                            // エディット中のテクスチャの場合
                            if (GUILayout.Button("-変更", uiParams.bStyle, buttonLWidth))
                            {
                                editTarget.Clear();
                            }
                        }
                        else
                        {
                            // エディット中以外のテクスチャの場合
                            if (GUILayout.Button("+変更", uiParams.bStyle, buttonLWidth))
                            {
                                editTarget.slotName = holder.currentSlot.Name;
                                editTarget.matNo    = matNo;
                                editTarget.propName = editTex.propName;
                                editTarget.propKey  = editTex.propKey;
                            }
                        }
                        GUILayout.Label(editTex.propName, uiParams.lStyle);
                        if (bTargetElement && editTex.type.hasShadow && editTex.propKey == ShaderPropType.MainTex.key)
                        {
                            if (GUILayout.Button("_ShadowTexに反映", uiParams.bStyleSC))
                            {
                                // 現在のFilterを_ShadowTexにも反映
                                textureModifier.DuplicateFilter(holder.currentMaid, holder.currentSlot.Name, material, editTex.propName, "_ShadowTex");
                            }
                        }
                    } finally {
                        GUILayout.EndHorizontal();
                    }

                    // テクスチャエディット用スライダー
                    if (bTargetElement)
                    {
                        textureModifier.ProcGUI(holder.currentMaid, holder.currentSlot.Name, material, editTex.propName);
                    }

                    float      height     = uiParams.itemHeight;
                    ComboBoxLO combo      = null;
                    bool       cbSelected = false;
                    if (editTex.toonType != ACCTexture.NONE)
                    {
                        if (combos.TryGetValue(editTex.propName, out combo))
                        {
                            if (combo.IsClickedComboButton)
                            {
                                height = combo.ItemCount * uiParams.itemHeight * 0.8f;
                            }
                        }
                        else
                        {
                            combo = new ComboBoxLO(new GUIContent("選"), ItemNames, uiParams.bStyle, uiParams.boxStyle, uiParams.listStyle, true);
                            combo.SetItemWidth(comboWidth);
                            combos[editTex.propName] = combo;
                            combo.SelectItem(editTex.editname);
                        }
                    }
                    GUILayout.BeginHorizontal(GUILayout.Height(height));
                    try {
                        bool   hideField = false;
                        string editName  = editTex.editname;
                        if (editTex.toonType != ACCTexture.NONE)
                        {
                            // 偽コンボボックス
                            int prevSelected = combo.SelectedItemIndex;
                            int selected     = combo.Show(uiParams.optBtnWidth);
                            if (selected != prevSelected)
                            {
                                editName   = ItemNames[selected].text;
                                cbSelected = true;
                            }
                            hideField = combo.IsClickedComboButton;
                        }
                        if (hideField)
                        {
                            uiParams.textStyle.fontSize = (int)(fontSizeS * 0.8);
                        }
                        editName = GUILayout.TextField(editName, uiParams.textStyle, contentWidth);
                        editTex.SetName(editName);

                        if (hideField)
                        {
                            uiParams.textStyle.fontSize = fontSize;
                        }

                        GUI.enabled = editTex.dirty;
                        if ((settings.toonComboAutoApply && cbSelected) ||
                            GUILayout.Button("適", uiParams.bStyle, uiParams.optBtnWidth))
                        {
                            Texture tex = ChangeTexFile(textureDir, editTex.editname, matNo, editTex.propName);
                            if (tex != null)
                            {
                                editTex.tex = tex;
                            }
                            editTex.dirty = false;
                        }
                        GUI.enabled = true;
                        if (GUILayout.Button("...", uiParams.bStyle, uiParams.optBtnWidth))
                        {
                            OpenFileBrowser(matNo, editTex);
                        }
                    } finally {
                        GUILayout.EndHorizontal();
                    }
                }
            } finally {
                GUILayout.EndVertical();
            }
        }
Esempio n. 2
0
        public void Show()
        {
            GUILayout.BeginVertical(inboxStyle);
            try {
                var matName = (expand? "- " : "+ ") + material.name;
                if (GUILayout.Button(matName, uiParams.lStyleC))
                {
                    expand = !expand;
                }
                if (!expand)
                {
                    return;
                }

                foreach (var editTex in edited)
                {
                    var bTargetElement = (matNo == editTarget.matNo && editTex.propKey == editTarget.propKey);

                    if (editTex.prop.Keyword != Keyword.NONE)
                    {
                        if (!material.IsKeywordEnabled(editTex.prop.KeywordString))
                        {
                            continue;
                        }
                    }

                    GUILayout.BeginHorizontal();
                    try {
                        // エディット用スライダーの開閉
                        if (!textureModifier.IsValidTarget(holder.CurrentMaid, holder.CurrentSlot.Name, material, editTex.propName))
                        {
                            // 参照先が Texture2D が取れなかった (例 : RenderTexture ) 場合は何もしない
                            var tmp = GUI.enabled;
                            GUI.enabled = false;
                            GUILayout.Button("+変更", uiParams.bStyle, buttonLWidth);
                            GUI.enabled = tmp;
                        }
                        else if (bTargetElement)
                        {
                            // エディット中のテクスチャの場合
                            if (GUILayout.Button("-変更", uiParams.bStyle, buttonLWidth))
                            {
                                editTarget.Clear();
                            }
                        }
                        else
                        {
                            // エディット中以外のテクスチャの場合
                            if (GUILayout.Button("+変更", uiParams.bStyle, buttonLWidth))
                            {
                                editTarget.slotName = holder.CurrentSlot.Name;
                                editTarget.matNo    = matNo;
                                editTarget.propName = editTex.propName;
                                editTarget.propKey  = editTex.propKey;
                            }
                        }
                        GUILayout.Label(editTex.propName, uiParams.lStyle);
                        if (bTargetElement && editTex.type.hasShadow && editTex.propKey == ShaderPropType.MainTex.key)
                        {
                            if (GUILayout.Button("_ShadowTexに反映", uiParams.bStyleSC))
                            {
                                // 現在のFilterを_ShadowTexにも反映
                                textureModifier.DuplicateFilter(holder.CurrentMaid, holder.CurrentSlot.Name, material, editTex.propName, "_ShadowTex");
                            }
                        }

                        if (GUILayout.Button("opt", uiParams.bStyleSC, restWidth))
                        {
                            editTex.expand = !editTex.expand;
                        }
                    } finally {
                        GUILayout.EndHorizontal();
                    }

                    // テクスチャエディット用スライダー
                    if (bTargetElement)
                    {
                        textureModifier.ProcGUI(holder.CurrentMaid, holder.CurrentSlot.Name, material, editTex.propName);
                    }

                    float      height     = uiParams.itemHeight;
                    ComboBoxLO combo      = null;
                    var        cbSelected = false;
                    if (editTex.toonType != ACCTexture.NONE)
                    {
                        if (combos.TryGetValue(editTex.propName, out combo))
                        {
                            if (combo.IsClickedComboButton)
                            {
                                height = combo.ItemCount * uiParams.itemHeight * 0.8f;
                            }
                        }
                        else
                        {
                            combo = new ComboBoxLO(new GUIContent("選"), ItemNames, uiParams.bStyle, uiParams.boxStyle, uiParams.listStyle, true);
                            combo.SetItemWidth(comboWidth);
                            combos[editTex.propName] = combo;
                            combo.SelectItem(editTex.editname);
                        }
                    }
                    GUILayout.BeginHorizontal(GUILayout.Height(height));
                    try {
                        var hideField = false;
                        var editName  = editTex.editname;
                        if (editTex.toonType != ACCTexture.NONE)
                        {
                            // 偽コンボボックス
                            var prevSelected = combo.SelectedItemIndex;
                            var selected     = combo.Show(uiParams.optBtnWidth);
                            if (selected != prevSelected)
                            {
                                editName   = ItemNames[selected].text;
                                cbSelected = true;
                            }
                            hideField = combo.IsClickedComboButton;
                        }
                        else
                        {
                            GUILayout.Label(string.Empty, uiParams.optBtnWidth);
                        }
                        if (hideField)
                        {
                            uiParams.textStyle.fontSize = (int)(fontSizeS * 0.8);
                        }
                        editName = GUILayout.TextField(editName, uiParams.textStyle, contentWidth);
                        editTex.SetName(editName);

                        if (hideField)
                        {
                            uiParams.textStyle.fontSize = fontSize;
                        }

                        GUI.enabled = editTex.dirty;
                        if ((settings.toonComboAutoApply && cbSelected) ||
                            GUILayout.Button("適", uiParams.bStyle, uiParams.optBtnWidth))
                        {
                            var tex = ChangeTexFile(textureDir, editTex.editname, matNo, editTex.propName);
                            if (tex != null)
                            {
                                editTex.tex = tex;
                            }
                            editTex.dirty = false;
                        }
                        GUI.enabled = true;
                        if (GUILayout.Button("...", uiParams.bStyle, uiParams.optBtnWidth))
                        {
                            OpenFileBrowser(matNo, editTex);
                        }
                    } finally {
                        GUILayout.EndHorizontal();
                    }

                    if (!editTex.expand)
                    {
                        continue;
                    }

                    GUILayout.BeginVertical();
                    try {
#if UNITY_5_6_OR_NEWER
                        var offset = material.GetTextureOffset(editTex.prop.propId);
                        var tex    = editTex;
                        if (DrawSliders("offset", ref offset, -1, 1, () => tex.original.texOffset))
                        {
                            material.SetTextureOffset(editTex.prop.propId, offset);
                        }

                        var scale = material.GetTextureScale(editTex.prop.propId);
                        if (DrawSliders("scale ", ref scale, 0.001f, 20f, () => tex.original.texScale, true))
                        {
                            material.SetTextureScale(editTex.prop.propId, scale);
                        }
#else
                        var offset = material.GetTextureOffset(editTex.prop.keyName);
                        var tex    = editTex;
                        if (DrawSliders("offset", ref offset, -1, 1, () => tex.original.texOffset))
                        {
                            material.SetTextureOffset(editTex.prop.keyName, offset);
                        }

                        var scale = material.GetTextureScale(editTex.prop.keyName);
                        if (DrawSliders("scale ", ref scale, 0.001f, 20f, () => tex.original.texScale, true))
                        {
                            material.SetTextureScale(editTex.prop.keyName, scale);
                        }
#endif
                    } finally {
                        GUILayout.EndVertical();
                    }
                }
            } finally {
                GUILayout.EndVertical();
            }
        }