public ChannelMixerControlView(string label, float minimum, float maximum, AbstractMaterialNode node, PropertyInfo propertyInfo) { m_Node = node; m_PropertyInfo = propertyInfo; m_ChannelMixer = (ChannelMixerNode.ChannelMixer)m_PropertyInfo.GetValue(m_Node, null); m_OutChannel = 0; m_Minimum = minimum; m_Maximum = maximum; if (propertyInfo.PropertyType != typeof(ChannelMixerNode.ChannelMixer)) { throw new ArgumentException("Property must be of type ChannelMixer.", "propertyInfo"); } label = label ?? ObjectNames.NicifyVariableName(propertyInfo.Name); if (!string.IsNullOrEmpty(label)) { Add(new Label(label)); } Action changedOutputRed = () => OnClickButton(0); var outputButtonRed = new Button(changedOutputRed); Add(outputButtonRed); Action changedOutputGreen = () => OnClickButton(1); var outputButtonGreen = new Button(changedOutputGreen); Add(outputButtonGreen); Action changedOutputBlue = () => OnClickButton(2); var outputButtonBlue = new Button(changedOutputBlue); Add(outputButtonBlue); Add(new Label("Red")); Action <float> changedRedIn = (s) => { OnChangeSlider(s, 0); }; m_RedSlider = new Slider(m_Minimum, m_Maximum, changedRedIn); Add(m_RedSlider); Add(new Label("Green")); Action <float> changedGreenIn = (s) => { OnChangeSlider(s, 1); }; m_GreenSlider = new Slider(m_Minimum, m_Maximum, changedGreenIn); Add(m_GreenSlider); Add(new Label("Blue")); Action <float> changedBlueIn = (s) => { OnChangeSlider(s, 2); }; m_BlueSlider = new Slider(m_Minimum, m_Maximum, changedBlueIn); Add(m_BlueSlider); m_Initialized = true; ResetSliders(); }
public ChannelMixerControlView(string label, float minimum, float maximum, AbstractMaterialNode node, PropertyInfo propertyInfo) { m_Node = node; m_PropertyInfo = propertyInfo; styleSheets.Add(Resources.Load <StyleSheet>("Styles/Controls/ChannelMixerControlView")); m_ChannelMixer = (ChannelMixerNode.ChannelMixer)m_PropertyInfo.GetValue(m_Node, null); m_OutChannel = 0; m_Minimum = minimum; m_Maximum = maximum; if (propertyInfo.PropertyType != typeof(ChannelMixerNode.ChannelMixer)) { throw new ArgumentException("Property must be of type ChannelMixer.", "propertyInfo"); } label = label ?? ObjectNames.NicifyVariableName(propertyInfo.Name); if (!string.IsNullOrEmpty(label)) { Add(new Label(label)); } var buttonPanel = new VisualElement { name = "buttonPanel" }; Action changedOutputRed = () => OnClickButton(0); var outputButtonRed = new Button(changedOutputRed); outputButtonRed.Add(new Label("R")); buttonPanel.Add(outputButtonRed); Action changedOutputGreen = () => OnClickButton(1); var outputButtonGreen = new Button(changedOutputGreen); outputButtonGreen.Add(new Label("G")); buttonPanel.Add(outputButtonGreen); Action changedOutputBlue = () => OnClickButton(2); var outputButtonBlue = new Button(changedOutputBlue); outputButtonBlue.Add(new Label("B")); buttonPanel.Add(outputButtonBlue); Add(buttonPanel); var redSliderPanel = new VisualElement { name = "sliderPanel" }; redSliderPanel.Add(new Label("R")); Action <float> changedRedIn = (s) => { OnChangeSlider(s, 0); }; m_RedSlider = new Slider(m_Minimum, m_Maximum); m_RedSlider.RegisterValueChangedCallback((evt) => OnChangeSlider(evt.newValue, 0)); redSliderPanel.Add(m_RedSlider); m_RedInputField = new FloatField { value = m_ChannelMixer.outRed.x }; m_RedInputField.RegisterCallback <ChangeEvent <double>, int>(OnChangeInputField, 0); redSliderPanel.Add(m_RedInputField); Add(redSliderPanel); var greenSliderPanel = new VisualElement { name = "sliderPanel" }; greenSliderPanel.Add(new Label("G")); m_GreenSlider = new Slider(m_Minimum, m_Maximum); m_GreenSlider.RegisterValueChangedCallback((evt) => OnChangeSlider(evt.newValue, 1)); greenSliderPanel.Add(m_GreenSlider); m_GreenInputField = new FloatField { value = m_ChannelMixer.outRed.y }; m_GreenInputField.RegisterCallback <ChangeEvent <double>, int>(OnChangeInputField, 1); greenSliderPanel.Add(m_GreenInputField); Add(greenSliderPanel); var blueSliderPanel = new VisualElement { name = "sliderPanel" }; blueSliderPanel.Add(new Label("B")); m_BlueSlider = new Slider(m_Minimum, m_Maximum); m_BlueSlider.RegisterValueChangedCallback((evt) => OnChangeSlider(evt.newValue, 2)); blueSliderPanel.Add(m_BlueSlider); m_BlueInputField = new FloatField { value = m_ChannelMixer.outRed.z }; m_BlueInputField.RegisterCallback <ChangeEvent <double>, int>(OnChangeInputField, 2); blueSliderPanel.Add(m_BlueInputField); Add(blueSliderPanel); m_Initialized = true; ResetSliders(); }