From 478d1f6ea049c8629cad7541a9cac0c041726be1 Mon Sep 17 00:00:00 2001 From: Ludovic LEROUGE - TheRed Games Date: Tue, 5 Mar 2024 15:02:18 +0100 Subject: [PATCH 1/5] fix: remove other modalities and slider, adapt the only one --- package/Editor/PromptWindow/PromptWindow.cs | 16 +------ package/Editor/PromptWindow/PromptWindowUI.cs | 16 ++++--- .../PromptWindow/Views/ControlNetView.cs | 47 ++++--------------- 3 files changed, 21 insertions(+), 58 deletions(-) diff --git a/package/Editor/PromptWindow/PromptWindow.cs b/package/Editor/PromptWindow/PromptWindow.cs index 852e5f2..6ae3767 100644 --- a/package/Editor/PromptWindow/PromptWindow.cs +++ b/package/Editor/PromptWindow/PromptWindow.cs @@ -207,21 +207,7 @@ private void PrepareAdvancedModalitySettings(out string modality, out string ope { string option1Name = promptWindowUI.dropdownOptions[promptWindowUI.selectedOption1Index - 1]; if (!modalitySettings.ContainsKey(option1Name)) - modalitySettings.Add(option1Name, $"{promptWindowUI.sliderValue1:0.00}"); - } - - if (promptWindowUI.selectedOption2Index > 0) - { - string option2Name = promptWindowUI.dropdownOptions[promptWindowUI.selectedOption2Index - 1]; - if (!modalitySettings.ContainsKey(option2Name)) - modalitySettings.Add(option2Name, $"{promptWindowUI.sliderValue2:0.00}"); - } - - if (promptWindowUI.selectedOption3Index > 0) - { - string option3Name = promptWindowUI.dropdownOptions[promptWindowUI.selectedOption3Index - 1]; - if (!modalitySettings.ContainsKey(option3Name)) - modalitySettings.Add(option3Name, $"{promptWindowUI.sliderValue3:0.00}"); + modalitySettings.Add(option1Name, $"{promptWindowUI.sliderValue:0.00}"); } modality = string.Join(",", modalitySettings.Select(kv => $"{kv.Key}:{float.Parse(kv.Value).ToString(CultureInfo.InvariantCulture)}")); diff --git a/package/Editor/PromptWindow/PromptWindowUI.cs b/package/Editor/PromptWindow/PromptWindowUI.cs index 0721965..c04da47 100644 --- a/package/Editor/PromptWindow/PromptWindowUI.cs +++ b/package/Editor/PromptWindow/PromptWindowUI.cs @@ -36,11 +36,16 @@ public partial class PromptWindowUI public string selectedPreset = ""; public int selectedOption1Index = 0; - public int selectedOption2Index = 0; - public int selectedOption3Index = 0; - public float sliderValue1 = 0.1f; - public float sliderValue2 = 0.1f; - public float sliderValue3 = 0.1f; + + /// + /// + /// + public int sliderDisplayedValue = 100; + + /// + /// Value from the guidance slider in controlNet options, use to send to generation + /// + public float sliderValue = 0.0f; internal bool isImageToImage = false; internal bool isControlNet = false; @@ -303,7 +308,6 @@ private Rect DrawUploadedImage(Rect dropArea) heightSliderValue = matchingHeight != -1 ? matchingHeight : currentHeight; selectedOption1Index = NearestValueIndex(widthSliderValue, allowedWidthValues); - selectedOption2Index = NearestValueIndex(heightSliderValue, allowedHeightValues); }); toolsMenu.DropDown(dropdownButtonRect); diff --git a/package/Editor/PromptWindow/Views/ControlNetView.cs b/package/Editor/PromptWindow/Views/ControlNetView.cs index a761d76..3f1ff8b 100644 --- a/package/Editor/PromptWindow/Views/ControlNetView.cs +++ b/package/Editor/PromptWindow/Views/ControlNetView.cs @@ -31,50 +31,23 @@ private void RenderControlNetFoldout() if (isAdvancedSettings) { GUILayout.BeginHorizontal(); - GUILayout.Label("Model 1", EditorStyles.label); + GUILayout.Label("Modality :", EditorStyles.label); List availableOptions1 = new List { "None" }; availableOptions1.AddRange(dropdownOptions); selectedOption1Index = EditorGUILayout.Popup(selectedOption1Index, availableOptions1.ToArray()); - GUILayout.Label("Slider 1", EditorStyles.label); - sliderValue1 = Mathf.Round(EditorGUILayout.Slider(Mathf.Clamp(sliderValue1, 0.1f, 1.0f), 0.1f, 1.0f) * 100) / 100; - GUILayout.EndHorizontal(); - if (selectedOption1Index > 0) - { - GUILayout.BeginHorizontal(); - GUILayout.Label("Model 2", EditorStyles.label); - - List availableOptions2 = new List { "None" }; - availableOptions2.AddRange(dropdownOptions); - availableOptions2.RemoveAt(selectedOption1Index); - selectedOption2Index = EditorGUILayout.Popup(selectedOption2Index, availableOptions2.ToArray()); - - GUILayout.Label("Slider 2", EditorStyles.label); - sliderValue2 = Mathf.Round(EditorGUILayout.Slider(Mathf.Clamp(sliderValue2, 0.1f, 1.0f), 0.1f, 1.0f) * 100) / 100; - GUILayout.EndHorizontal(); - } - - if (selectedOption2Index > 0) - { - GUILayout.BeginHorizontal(); - GUILayout.Label("Model 3", EditorStyles.label); - - List availableOptions3 = new List { "None" }; - availableOptions3.AddRange(dropdownOptions); - int option1Index = Array.IndexOf(dropdownOptions, availableOptions1[selectedOption1Index]); - int option2Index = Array.IndexOf(dropdownOptions, dropdownOptions[selectedOption2Index]); - - availableOptions3.RemoveAt(option1Index + 1); - availableOptions3.RemoveAt(option2Index); - - selectedOption3Index = EditorGUILayout.Popup(selectedOption3Index, availableOptions3.ToArray()); - - GUILayout.Label("Slider 3", EditorStyles.label); - sliderValue3 = Mathf.Round(EditorGUILayout.Slider(Mathf.Clamp(sliderValue3, 0.1f, 1.0f), 0.1f, 1.0f) * 100) / 100; - GUILayout.EndHorizontal(); + { + GUILayout.Label("Guidance :", EditorStyles.label); + sliderDisplayedValue = (int)EditorGUILayout.Slider(Mathf.Clamp(sliderDisplayedValue, 0, 100), 0, 100); + sliderValue = sliderDisplayedValue / 100.0f; + if (sliderValue == 0) + { + sliderValue = 0.1f; + } } + GUILayout.EndHorizontal(); } else { From 6401f1233d7eb46ea1a31228e4b7e6c0b6af465f Mon Sep 17 00:00:00 2001 From: Ludovic LEROUGE - TheRed Games Date: Tue, 5 Mar 2024 16:42:24 +0100 Subject: [PATCH 2/5] fix: slider value minimum to send to inference --- package/Editor/PromptWindow/PromptWindow.cs | 2 ++ package/Editor/PromptWindow/Views/ControlNetView.cs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/package/Editor/PromptWindow/PromptWindow.cs b/package/Editor/PromptWindow/PromptWindow.cs index 6ae3767..c757ab6 100644 --- a/package/Editor/PromptWindow/PromptWindow.cs +++ b/package/Editor/PromptWindow/PromptWindow.cs @@ -207,7 +207,9 @@ private void PrepareAdvancedModalitySettings(out string modality, out string ope { string option1Name = promptWindowUI.dropdownOptions[promptWindowUI.selectedOption1Index - 1]; if (!modalitySettings.ContainsKey(option1Name)) + { modalitySettings.Add(option1Name, $"{promptWindowUI.sliderValue:0.00}"); + } } modality = string.Join(",", modalitySettings.Select(kv => $"{kv.Key}:{float.Parse(kv.Value).ToString(CultureInfo.InvariantCulture)}")); diff --git a/package/Editor/PromptWindow/Views/ControlNetView.cs b/package/Editor/PromptWindow/Views/ControlNetView.cs index 3f1ff8b..2e657ce 100644 --- a/package/Editor/PromptWindow/Views/ControlNetView.cs +++ b/package/Editor/PromptWindow/Views/ControlNetView.cs @@ -44,7 +44,7 @@ private void RenderControlNetFoldout() sliderValue = sliderDisplayedValue / 100.0f; if (sliderValue == 0) { - sliderValue = 0.1f; + sliderValue = 0.01f; } } GUILayout.EndHorizontal(); From cd75e0bd835f0aeaef88a08856133368947d6b4c Mon Sep 17 00:00:00 2001 From: Ludovic LEROUGE - TheRed Games Date: Wed, 6 Mar 2024 09:16:09 +0100 Subject: [PATCH 3/5] docs: slider variable documentation --- package/Editor/PromptWindow/PromptWindowUI.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/Editor/PromptWindow/PromptWindowUI.cs b/package/Editor/PromptWindow/PromptWindowUI.cs index c04da47..d8f4347 100644 --- a/package/Editor/PromptWindow/PromptWindowUI.cs +++ b/package/Editor/PromptWindow/PromptWindowUI.cs @@ -38,7 +38,7 @@ public partial class PromptWindowUI public int selectedOption1Index = 0; /// - /// + /// Variable to display in interface on slider element. /// public int sliderDisplayedValue = 100; From e5ee70b448828ab6c07d6f1038dd0385e8690bb8 Mon Sep 17 00:00:00 2001 From: TheRed Games <30622829+TheLLspectre@users.noreply.github.com> Date: Thu, 7 Mar 2024 14:53:34 +0100 Subject: [PATCH 4/5] fix: rename slider --- package/Editor/PromptWindow/Views/ControlNetView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/Editor/PromptWindow/Views/ControlNetView.cs b/package/Editor/PromptWindow/Views/ControlNetView.cs index 2e657ce..ad74c91 100644 --- a/package/Editor/PromptWindow/Views/ControlNetView.cs +++ b/package/Editor/PromptWindow/Views/ControlNetView.cs @@ -39,7 +39,7 @@ private void RenderControlNetFoldout() if (selectedOption1Index > 0) { - GUILayout.Label("Guidance :", EditorStyles.label); + GUILayout.Label("Influence :", EditorStyles.label); sliderDisplayedValue = (int)EditorGUILayout.Slider(Mathf.Clamp(sliderDisplayedValue, 0, 100), 0, 100); sliderValue = sliderDisplayedValue / 100.0f; if (sliderValue == 0) From 8b7e241c859713956c71e5255575a09946cc776f Mon Sep 17 00:00:00 2001 From: TheRed Games <30622829+TheLLspectre@users.noreply.github.com> Date: Thu, 7 Mar 2024 15:00:53 +0100 Subject: [PATCH 5/5] fix: rename selected option values variables --- package/Editor/PromptWindow/PromptWindow.cs | 8 ++++---- package/Editor/PromptWindow/PromptWindowUI.cs | 8 ++++++-- package/Editor/PromptWindow/Views/ControlNetView.cs | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/package/Editor/PromptWindow/PromptWindow.cs b/package/Editor/PromptWindow/PromptWindow.cs index c757ab6..a4b80bf 100644 --- a/package/Editor/PromptWindow/PromptWindow.cs +++ b/package/Editor/PromptWindow/PromptWindow.cs @@ -203,12 +203,12 @@ private void PrepareAdvancedModalitySettings(out string modality, out string ope { operationType = "controlnet"; - if (promptWindowUI.selectedOption1Index > 0) + if (promptWindowUI.selectedOptionIndex > 0) { - string option1Name = promptWindowUI.dropdownOptions[promptWindowUI.selectedOption1Index - 1]; - if (!modalitySettings.ContainsKey(option1Name)) + string optionName = promptWindowUI.dropdownOptions[promptWindowUI.selectedOptionIndex - 1]; + if (!modalitySettings.ContainsKey(optionName)) { - modalitySettings.Add(option1Name, $"{promptWindowUI.sliderValue:0.00}"); + modalitySettings.Add(optionName, $"{promptWindowUI.sliderValue:0.00}"); } } diff --git a/package/Editor/PromptWindow/PromptWindowUI.cs b/package/Editor/PromptWindow/PromptWindowUI.cs index d8f4347..dc0a610 100644 --- a/package/Editor/PromptWindow/PromptWindowUI.cs +++ b/package/Editor/PromptWindow/PromptWindowUI.cs @@ -35,7 +35,11 @@ public partial class PromptWindowUI }; public string selectedPreset = ""; - public int selectedOption1Index = 0; + + /// + /// Correspond of the index value selected from the modalities dropdown value + /// + public int selectedOptionIndex = 0; /// /// Variable to display in interface on slider element. @@ -307,7 +311,7 @@ private Rect DrawUploadedImage(Rect dropArea) widthSliderValue = matchingWidth != -1 ? matchingWidth : currentWidth; heightSliderValue = matchingHeight != -1 ? matchingHeight : currentHeight; - selectedOption1Index = NearestValueIndex(widthSliderValue, allowedWidthValues); + selectedOptionIndex = NearestValueIndex(widthSliderValue, allowedWidthValues); }); toolsMenu.DropDown(dropdownButtonRect); diff --git a/package/Editor/PromptWindow/Views/ControlNetView.cs b/package/Editor/PromptWindow/Views/ControlNetView.cs index ad74c91..83d2d6d 100644 --- a/package/Editor/PromptWindow/Views/ControlNetView.cs +++ b/package/Editor/PromptWindow/Views/ControlNetView.cs @@ -35,9 +35,9 @@ private void RenderControlNetFoldout() List availableOptions1 = new List { "None" }; availableOptions1.AddRange(dropdownOptions); - selectedOption1Index = EditorGUILayout.Popup(selectedOption1Index, availableOptions1.ToArray()); + selectedOptionIndex = EditorGUILayout.Popup(selectedOptionIndex, availableOptions1.ToArray()); - if (selectedOption1Index > 0) + if (selectedOptionIndex > 0) { GUILayout.Label("Influence :", EditorStyles.label); sliderDisplayedValue = (int)EditorGUILayout.Slider(Mathf.Clamp(sliderDisplayedValue, 0, 100), 0, 100);