|
|
|
|
|
|
Slider m_GreenSlider; |
|
|
|
Slider m_BlueSlider; |
|
|
|
|
|
|
|
FloatField m_RedInputField; |
|
|
|
FloatField m_GreenInputField; |
|
|
|
FloatField m_BlueInputField; |
|
|
|
|
|
|
|
|
|
|
|
int m_UndoGroup = -1; |
|
|
|
|
|
|
|
public ChannelMixerControlView(string label, float minimum, float maximum, AbstractMaterialNode node, PropertyInfo propertyInfo) |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(label)) |
|
|
|
Add(new Label(label)); |
|
|
|
|
|
|
|
var buttonPanel = new VisualElement { name = "buttonPanel" }; |
|
|
|
Add(outputButtonRed); |
|
|
|
outputButtonRed.Add(new Label("R")); |
|
|
|
buttonPanel.Add(outputButtonRed); |
|
|
|
Add(outputButtonGreen); |
|
|
|
outputButtonGreen.Add(new Label("G")); |
|
|
|
buttonPanel.Add(outputButtonGreen); |
|
|
|
Add(outputButtonBlue); |
|
|
|
outputButtonBlue.Add(new Label("B")); |
|
|
|
buttonPanel.Add(outputButtonBlue); |
|
|
|
Add(new Label("Red")); |
|
|
|
Add(buttonPanel); |
|
|
|
|
|
|
|
var redSliderPanel = new VisualElement { name = "sliderPanel" }; |
|
|
|
redSliderPanel.Add(new Label("R")); |
|
|
|
Add(m_RedSlider); |
|
|
|
redSliderPanel.Add(m_RedSlider); |
|
|
|
m_RedInputField = new FloatField { value = m_ChannelMixer.outRed.x }; |
|
|
|
m_RedInputField.OnValueChanged(OnChangeRedInputField); |
|
|
|
redSliderPanel.Add(m_RedInputField); |
|
|
|
Add(redSliderPanel); |
|
|
|
Add(new Label("Green")); |
|
|
|
var greenSliderPanel = new VisualElement { name = "sliderPanel" }; |
|
|
|
greenSliderPanel.Add(new Label("G")); |
|
|
|
Add(m_GreenSlider); |
|
|
|
greenSliderPanel.Add(m_GreenSlider); |
|
|
|
m_GreenInputField = new FloatField { value = m_ChannelMixer.outRed.y }; |
|
|
|
m_GreenInputField.OnValueChanged(OnChangeGreenInputField); |
|
|
|
greenSliderPanel.Add(m_GreenInputField); |
|
|
|
Add(greenSliderPanel); |
|
|
|
Add(new Label("Blue")); |
|
|
|
var blueSliderPanel = new VisualElement { name = "sliderPanel" }; |
|
|
|
blueSliderPanel.Add(new Label("B")); |
|
|
|
Add(m_BlueSlider); |
|
|
|
blueSliderPanel.Add(m_BlueSlider); |
|
|
|
m_BlueInputField = new FloatField { value = m_ChannelMixer.outRed.z }; |
|
|
|
m_BlueInputField.OnValueChanged(OnChangeBlueInputField); |
|
|
|
blueSliderPanel.Add(m_BlueInputField); |
|
|
|
Add(blueSliderPanel); |
|
|
|
|
|
|
|
m_Initialized = true; |
|
|
|
ResetSliders(); |
|
|
|
|
|
|
m_ChannelMixer.outRed[inChannel] = value; |
|
|
|
break; |
|
|
|
} |
|
|
|
switch(inChannel) |
|
|
|
{ |
|
|
|
case 1: |
|
|
|
m_GreenInputField.value = value; |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
m_BlueInputField.value = value; |
|
|
|
break; |
|
|
|
default: |
|
|
|
m_RedInputField.value = value; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void OnChangeRedInputField(ChangeEvent<double> evt) |
|
|
|
{ |
|
|
|
if (!m_Initialized) |
|
|
|
return; |
|
|
|
var value = Mathf.Max(Mathf.Min((float)evt.newValue, m_Maximum), m_Minimum); |
|
|
|
m_Node.owner.owner.RegisterCompleteObjectUndo("Input Field Change"); |
|
|
|
switch (m_OutChannel) |
|
|
|
{ |
|
|
|
case 1: |
|
|
|
m_ChannelMixer.outGreen[0] = value; |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
m_ChannelMixer.outBlue[0] = value; |
|
|
|
break; |
|
|
|
default: |
|
|
|
m_ChannelMixer.outRed[0] = value; |
|
|
|
break; |
|
|
|
} |
|
|
|
m_RedSlider.value = value; |
|
|
|
m_PropertyInfo.SetValue(m_Node, m_ChannelMixer, null); |
|
|
|
Dirty(ChangeType.Repaint); |
|
|
|
} |
|
|
|
|
|
|
|
void OnChangeGreenInputField(ChangeEvent<double> evt) |
|
|
|
{ |
|
|
|
if (!m_Initialized) |
|
|
|
return; |
|
|
|
var value = Mathf.Max(Mathf.Min((float)evt.newValue, m_Maximum), m_Minimum); |
|
|
|
m_Node.owner.owner.RegisterCompleteObjectUndo("Input Field Change"); |
|
|
|
switch (m_OutChannel) |
|
|
|
{ |
|
|
|
case 1: |
|
|
|
m_ChannelMixer.outGreen[1] = value; |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
m_ChannelMixer.outBlue[1] = value; |
|
|
|
break; |
|
|
|
default: |
|
|
|
m_ChannelMixer.outRed[1] = value; |
|
|
|
break; |
|
|
|
} |
|
|
|
m_GreenSlider.value = value; |
|
|
|
m_PropertyInfo.SetValue(m_Node, m_ChannelMixer, null); |
|
|
|
Dirty(ChangeType.Repaint); |
|
|
|
} |
|
|
|
|
|
|
|
void OnChangeBlueInputField(ChangeEvent<double> evt) |
|
|
|
{ |
|
|
|
if (!m_Initialized) |
|
|
|
return; |
|
|
|
var value = Mathf.Max(Mathf.Min((float)evt.newValue, m_Maximum), m_Minimum); |
|
|
|
m_Node.owner.owner.RegisterCompleteObjectUndo("Input Field Change"); |
|
|
|
switch (m_OutChannel) |
|
|
|
{ |
|
|
|
case 1: |
|
|
|
m_ChannelMixer.outGreen[2] = value; |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
m_ChannelMixer.outBlue[2] = value; |
|
|
|
break; |
|
|
|
default: |
|
|
|
m_ChannelMixer.outRed[2] = value; |
|
|
|
break; |
|
|
|
} |
|
|
|
m_BlueSlider.value = value; |
|
|
|
m_PropertyInfo.SetValue(m_Node, m_ChannelMixer, null); |
|
|
|
Dirty(ChangeType.Repaint); |
|
|
|
} |
|
|
|
|
|
|
|
void OnClickButton(int outChannel) |
|
|
|