/// <summary> /// Color changed handler. /// </summary> /// <param name="control">Event source.</param> protected virtual void OnColorChanged(Controls.Control control) { HSVColorPicker picker = control as HSVColorPicker; SetTextFromColor(picker.SelectedColor); DoChanged(); }
/// <summary> /// Color changed handler. /// </summary> /// <param name="control">Event source.</param> protected virtual void OnColorChanged(Gwen.Controls.ControlBase control, EventArgs args) { HSVColorPicker picker = control as HSVColorPicker; SetTextFromColor(picker.SelectedColor); DoChanged(); }
public override void Init() { try { TitleUITextField(); color = new JSONStorableColor("Color", HSVColorPicker.RGBToHSV(1f, 1f, 1f), _ => SyncMats()); RegisterColor(color); CreateColorPicker(color, true); FloatSlider(ref alpha, "Color Alpha", 1, _ => { SyncMats(); }, 0, 2, true); renderOriginal = new JSONStorableBool("Render Original Material", true); RegisterBool(renderOriginal); CreateToggle(renderOriginal, false); mode = new JSONStorableBool("Mode", true, (bool _) => SyncMats()); CreateToggle(mode, false); RegisterUrl(loadedShaderPath); CreateButton("Rescan active clothes").button.onClick.AddListener(() => { StartCoroutine(Rebuild()); }); } catch (Exception e) { Log.Error($"{e}"); } }
/// <summary> /// Color changed handler. /// </summary> /// <param name="control">Event source.</param> protected virtual void onColorChanged(Control.ControlBase control, EventArgs args) { HSVColorPicker picker = control as HSVColorPicker; setTextFromColor(picker.SelectedColor); doChanged(); }
void OnColorChanged(Base control) { HSVColorPicker picker = control as HSVColorPicker; m_CurrentColorButton.Color = picker.SelectedColor; SetColors(); }
protected void BuildUIControls() { //Diff Color HSVColor diffColorHSVC = HSVColorPicker.RGBToHSV(1f, 1f, 1f); jDiffColor = new JSONStorableColor("DiffuseColor", diffColorHSVC, SetDiffColor); RegisterColor(jDiffColor); CreateColorPicker(jDiffColor, true); //Specular Color HSVColor specColorHSVC = HSVColorPicker.RGBToHSV(1f, 1f, 1f); jSpecColor = new JSONStorableColor("SpecularColor", specColorHSVC, SetSpecColor); RegisterColor(jSpecColor); CreateColorPicker(jSpecColor, true); // Specular Intensity jSpecIntensityFloat = new JSONStorableFloat("SpecularIntensity", 0.5f, SetSpecIntensity, 0f, 1f, true); RegisterFloat(jSpecIntensityFloat); specIntensitySlider = CreateSlider(jSpecIntensityFloat); // Specular Sharpness jSpecSharpnessFloat = new JSONStorableFloat("SpecularSharpness", 6f, SetSpecSharpness, 0f, 10f, true); RegisterFloat(jSpecSharpnessFloat); specSharpnessSlider = CreateSlider(jSpecSharpnessFloat); // Specular Fresnel jSpecFresnelFloat = new JSONStorableFloat("SpecularFresnel", 0f, SetSpecFresnel, 0f, 1f, true); RegisterFloat(jSpecFresnelFloat); specFresnelSlider = CreateSlider(jSpecFresnelFloat); // Diffuse Offset jDiffOffsetFloat = new JSONStorableFloat("DiffuseOffset", 0f, SetDiffOffset, -1f, 1f, true); RegisterFloat(jDiffOffsetFloat); diffOffsetSlider = CreateSlider(jDiffOffsetFloat); // Spec Offset jSpecOffsetFloat = new JSONStorableFloat("SpecularOffset", 0f, SetSpecOffset, -1f, 1f, true); RegisterFloat(jSpecOffsetFloat); specOffsetSlider = CreateSlider(jSpecOffsetFloat); // Gloss Offset jGlossOffsetFloat = new JSONStorableFloat("GlossOffset", 0.8f, SetGlossOffset, 0, 1f, true); RegisterFloat(jGlossOffsetFloat); glossOffsetSlider = CreateSlider(jGlossOffsetFloat); // IBL Filter (affects Global Illum Skybox ?!) jIBLFilterFloat = new JSONStorableFloat("IBLFilter", 0f, SetIBLFilter, 0, 1f, true); RegisterFloat(jIBLFilterFloat); iBLFilterSlider = CreateSlider(jIBLFilterFloat); //Subdermis Color HSVColor subdermisColorHSVC = HSVColorPicker.RGBToHSV(1f, 1f, 1f); jSubdermisColor = new JSONStorableColor("SubdermisColor", subdermisColorHSVC, SetSubdermisColor); RegisterColor(jSubdermisColor); CreateColorPicker(jSubdermisColor, true); }
protected void SetupPluginUI() { List <string> choices = new List <string>(); choices.Add("None"); choices.Add("FPS"); choices.Add("Load Dir"); choices.Add("Total Atoms"); JSONStorableStringChooser jsonTypeTopLeft = new JSONStorableStringChooser("TopLeft", choices, typeTopLeft, "Top Left", SetTopLeft); UIDynamicPopup dropdownTopLeft = CreatePopup(jsonTypeTopLeft); dropdownTopLeft.labelWidth = 300f; JSONStorableStringChooser jsonTypeTopRight = new JSONStorableStringChooser("TopRight", choices, typeTopRight, "Top Right", SetTopRight); UIDynamicPopup dropdownTopRight = CreatePopup(jsonTypeTopRight, true); dropdownTopRight.labelWidth = 300f; JSONStorableStringChooser jsonTypeBottomLeft = new JSONStorableStringChooser("BottomLeft", choices, typeBottomLeft, "Bottom Left", SetBottomLeft); UIDynamicPopup dropdownBottomLeft = CreatePopup(jsonTypeBottomLeft); dropdownBottomLeft.labelWidth = 300f; JSONStorableStringChooser jsonTypeBottomRight = new JSONStorableStringChooser("BottomRight", choices, typeBottomRight, "Bottom Right", SetBottomRight); UIDynamicPopup dropdownBottomRight = CreatePopup(jsonTypeBottomRight, true); dropdownBottomRight.labelWidth = 300f; // let user adjust scale and top for HMD viewport differences and personal preference. JSONStorableFloat jsonTopOffset = new JSONStorableFloat("Top Offset", topOffset, SetTopOffset, -2f, +2f, true); RegisterFloat(jsonTopOffset); sliderTopOffset = CreateSlider(jsonTopOffset); JSONStorableFloat jsonScale = new JSONStorableFloat("HUD Scale", hudScale, SetScale, 10f, 200f, true); RegisterFloat(jsonScale); sliderScale = CreateSlider(jsonScale); JSONStorableFloat jsonFontSize = new JSONStorableFloat("Text Size", fontSize, SetFontSize, 10f, 100f, true); RegisterFloat(jsonFontSize); sliderFontSize = CreateSlider(jsonFontSize); // JSONStorableColor example HSVColor hsvc = HSVColorPicker.RGBToHSV(textColor.r, textColor.g, textColor.b); JSONStorableColor jsonTextColor = new JSONStorableColor("Text Color", hsvc, SetTextColor); RegisterColor(jsonTextColor); CreateColorPicker(jsonTextColor, true); }
public ColorPickers(ControlBase parent) : base(parent) { ColorPicker rgbPicker = new ColorPicker(this); rgbPicker.SetPosition(10, 10); rgbPicker.ColorChanged += ColorChanged; HSVColorPicker hsvPicker = new HSVColorPicker(this); hsvPicker.SetPosition(300, 10); hsvPicker.ColorChanged += ColorChanged; }
private void ColorPicker(List <Material> mat, string shaderParamName, string displayname = null) { if (displayname == null) { displayname = shaderParamName; } var picker = new JSONStorableColor(displayname, HSVColorPicker.RGBToHSV(1f, 1f, 1f), c => mat.ForEach(m => m.SetColor(shaderParamName, c.colorPicker.currentColor)) ); script.RegisterColor(picker); script.CreateColorPicker(picker, true); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); ColorPicker rgbPicker = new ColorPicker(this, Color.White); rgbPicker.SetPosition(10, 10); rgbPicker.ColorChanged += ColorChanged; HSVColorPicker hsvPicker = new HSVColorPicker(this); hsvPicker.SetPosition(300, 10); hsvPicker.ColorChanged += ColorChanged; }
/// <summary> /// Color-select button press handler. /// </summary> /// <param name="control">Event source.</param> protected virtual void onButtonPressed(Control.ControlBase control, EventArgs args) { Menu menu = new Menu(GetCanvas()); menu.SetSize(256, 180); menu.DeleteOnClose = true; menu.IconMarginDisabled = true; HSVColorPicker picker = new HSVColorPicker(menu); picker.Dock = Pos.Fill; picker.SetSize(256, 128); picker.SetColor(getColorFromText(), false, true); picker.ColorChanged += onColorChanged; menu.Open(Pos.Right | Pos.Top); }
/// <summary> /// Color-select button press handler. /// </summary> /// <param name="control">Event source.</param> protected virtual void OnButtonPressed(Control.Base control, EventArgs args) { Menu menu = new Menu(GetCanvas()); menu.SetSize(256, 180); menu.DeleteOnClose = true; menu.IconMarginDisabled = true; HSVColorPicker picker = new HSVColorPicker(menu); picker.Dock = Pos.Fill; picker.SetSize(256, 128); string[] split = m_TextBox.Text.Split(' '); picker.SetColor(GetColorFromText(), false, true); picker.ColorChanged += OnColorChanged; menu.Open(Pos.Right | Pos.Top); }
void ShowColorDialog(ColorButton colorButton) { m_CurrentColorButton = colorButton; Alt.GUI.Temporary.Gwen.Control.Menu menu = new Alt.GUI.Temporary.Gwen.Control.Menu(GetCanvas()); menu.SetSize(256, 180); menu.DeleteOnClose = true; menu.IconMarginDisabled = true; HSVColorPicker picker = new HSVColorPicker(menu); picker.Dock = Pos.Fill; picker.SetSize(256, 128); picker.SetColor(m_CurrentColorButton.Color, false, true); picker.ColorChanged += OnColorChanged; menu.Open(Pos.Right | Pos.Top); }
/// <summary> /// Color-select button press handler. /// </summary> /// <param name="control">Event source.</param> protected virtual void OnButtonPressed(Controls.Control control) { Menu menu = new Menu(GetCanvas()); menu.SetSize(256, 180); menu.DeleteOnClose = true; menu.IconMarginDisabled = true; HSVColorPicker picker = new HSVColorPicker(menu); picker.Dock = Pos.Fill; picker.SetSize(256, 128); String[] split = m_TextBox.Text.Split(' '); picker.SetColor(GetColorFromText(), false, true); picker.ColorChanged += OnColorChanged; menu.Open(Pos.Right | Pos.Top); }
public ColorPickersTest(ControlBase parent) : base(parent) { /* RGB Picker */ { ColorPicker rgbPicker = new ColorPicker(this); rgbPicker.Dock = Net.Dock.Top; rgbPicker.ColorChanged += ColorChanged; } /* HSVColorPicker */ { HSVColorPicker hsvPicker = new HSVColorPicker(this); hsvPicker.Dock = Net.Dock.Fill; hsvPicker.HorizontalAlignment = Net.HorizontalAlignment.Left; hsvPicker.VerticalAlignment = Net.VerticalAlignment.Top; hsvPicker.ColorChanged += ColorChanged; } /* HSVColorPicker in Window */ { WindowTest window = new WindowTest(base.GetCanvas()); window.Size = new Net.Size(300, 200); window.Collapse(); DockLayout layout = new DockLayout(window); HSVColorPicker hsvPicker = new HSVColorPicker(layout); hsvPicker.Margin = Net.Margin.Two; hsvPicker.Dock = Net.Dock.Fill; hsvPicker.ColorChanged += ColorChanged; Button OpenWindow = new Button(this); OpenWindow.Dock = Net.Dock.Bottom; OpenWindow.HorizontalAlignment = Net.HorizontalAlignment.Left; OpenWindow.Text = "Open Window"; OpenWindow.Clicked += delegate(ControlBase sender, ClickedEventArgs args) { window.Show(); }; } }
public ColorPickers(Base parent) : base(parent) { /* RGB Picker */ { ColorPicker rgbPicker = new ColorPicker(this); rgbPicker.SetPosition(10, 10); rgbPicker.ColorChanged += ColorChanged; } /* HSVColorPicker */ { HSVColorPicker hsvPicker = new HSVColorPicker(this); hsvPicker.SetPosition(300, 10); hsvPicker.ColorChanged += ColorChanged; } /* HSVColorPicker in Window */ { Control.WindowControl Window = new WindowControl(this); Window.SetSize(300, 300); Window.Hide(); HSVColorPicker hsvPicker = new HSVColorPicker(Window); hsvPicker.SetPosition(10, 10); hsvPicker.ColorChanged += ColorChanged; Control.Button OpenWindow = new Control.Button(this); OpenWindow.SetPosition(10, 200); OpenWindow.SetSize(200, 20); OpenWindow.Text = "Open Window"; OpenWindow.Clicked += delegate(Base sender, ClickedEventArgs args) { Window.Show(); }; } }
public override void Init() { try { color = new JSONStorableColor("Color", HSVColorPicker.RGBToHSV(1f, 1f, 1f), _ => SyncMats()); RegisterColor(color); CreateColorPicker(color, true); FloatSlider(ref alpha, "Color Alpha", 1, _ => { SyncMats(); }, 0, 1, true); renderOriginal = new JSONStorableBool("Render Original Material", true); RegisterBool(renderOriginal); CreateToggle(renderOriginal, false); RegisterUrl(loadedShaderPath); CreateButton("Rescan active clothes").button.onClick.AddListener(() => { StartCoroutine(Rebuild()); }); StartCoroutine(LoadShaderAndInit()); } catch (Exception e) { SuperController.LogError("Exception caught: " + e); } }
/// <summary> /// Color-select button press handler. /// </summary> /// <param name="control">Event source.</param> protected virtual void OnButtonPressed(Control.ControlBase control, EventArgs args) { Canvas canvas = GetCanvas(); canvas.CloseMenus(); Popup popup = new Popup(canvas); popup.DeleteOnClose = true; popup.IsHidden = false; popup.BringToFront(); HSVColorPicker picker = new HSVColorPicker(popup); picker.SetColor(GetColorFromText(), false, true); picker.ColorChanged += OnColorChanged; Point p = m_Button.LocalPosToCanvas(Point.Zero); popup.DoMeasure(canvas.ActualSize); popup.DoArrange(new Rectangle(p.X + m_Button.ActualWidth - popup.MeasuredSize.Width, p.Y + ActualHeight, popup.MeasuredSize.Width, popup.MeasuredSize.Height)); popup.Open(new Point(p.X + m_Button.ActualWidth - popup.MeasuredSize.Width, p.Y + ActualHeight)); }
// IMPORTANT - DO NOT make custom enums. The dynamic C# complier crashes Unity when it encounters these for // some reason // IMPORTANT - DO NOT OVERRIDE Awake() as it is used internally by MVRScript - instead use Init() function which // is called right after creation public override void Init() { try { // put init code in here SuperController.LogMessage("Template Loaded"); // create custom JSON storable params here if you want them to be stored with scene JSON // types are JSONStorableFloat, JSONStorableBool, JSONStorableString, JSONStorableStringChooser // JSONStorableColor // JSONStorableFloat example JSONStorableFloat jfloat = new JSONStorableFloat("FooParam", 0f, DummyFloatCallback, 0f, 5f, true); RegisterFloat(jfloat); dslider = CreateSlider(jfloat); // button example dbutton = CreateButton("FooButton"); if (dbutton != null) { dbutton.button.onClick.AddListener(DummyButtonCallback); } // JSONStorableColor example HSVColor hsvc = HSVColorPicker.RGBToHSV(1f, 0f, 0f); JSONStorableColor jcolor = new JSONStorableColor("FooColor", hsvc, DummyColorCallback); RegisterColor(jcolor); CreateColorPicker(jcolor); // JSONStorableString example jstring = new JSONStorableString("FooString", ""); // register tells engine you want value saved in json file during save and also make it available to // animation/trigger system //RegisterString(jstring); dtext = CreateTextField(jstring); // JSONStorableStringChooser example List <string> choices = new List <string>(); choices.Add("None"); choices.Add("Choice1"); choices.Add("Choice2"); choices.Add("Choice3"); JSONStorableStringChooser jchooser = new JSONStorableStringChooser("FooChooser", choices, "None", "Choose Form Of Destruction", DummyChooserCallback); UIDynamicPopup udp = CreatePopup(jchooser, true); //CreateScrollablePopup(jchooser, true); udp.labelWidth = 300f; JSONStorableFloat jfloat2 = new JSONStorableFloat("FooParam2", 0f, 0f, 1f); CreateSlider(jfloat2, true); // spacer example UIDynamic spacer = CreateSpacer(true); // give the popup some room spacer.height = 400f; // JSONStorableToggle example JSONStorableBool jbool = new JSONStorableBool("FooBool", true); CreateToggle(jbool, true); } catch (Exception e) { SuperController.LogError("Exception caught: " + e); } }