您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
32 行
1.0 KiB
32 行
1.0 KiB
using UnityEditor.Experimental.UIElements;
|
|
using UnityEditor.Graphing;
|
|
using UnityEngine;
|
|
using UnityEngine.Experimental.UIElements;
|
|
|
|
namespace UnityEditor.ShaderGraph.Drawing.Slots
|
|
{
|
|
public class ColorRGBSlotControlView : VisualElement
|
|
{
|
|
ColorRGBMaterialSlot m_Slot;
|
|
|
|
public ColorRGBSlotControlView(ColorRGBMaterialSlot slot)
|
|
{
|
|
AddStyleSheetPath("Styles/Controls/ColorRGBSlotControlView");
|
|
m_Slot = slot;
|
|
var colorField = new ColorField
|
|
{
|
|
value = new Color(slot.value.x, slot.value.y, slot.value.z, 0),
|
|
showEyeDropper = false, showAlpha = false
|
|
};
|
|
colorField.OnValueChanged(OnValueChanged);
|
|
Add(colorField);
|
|
}
|
|
|
|
void OnValueChanged(ChangeEvent<Color> evt)
|
|
{
|
|
m_Slot.owner.owner.owner.RegisterCompleteObjectUndo("Color Change");
|
|
m_Slot.value = new Vector3(evt.newValue.r, evt.newValue.g, evt.newValue.b);
|
|
m_Slot.owner.Dirty(ModificationScope.Node);
|
|
}
|
|
}
|
|
}
|