Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions com.unity.visualeffectgraph/Editor/Controls/VFXColorField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ VisualElement CreateColorContainer()
return m_Container;
}

bool m_ShowAlpha = true;
private bool m_ShowAlpha = true;
private Color m_InitialColor;

public bool showAlpha
{
Expand Down Expand Up @@ -137,9 +138,28 @@ VisualElement CreateEyeDropper()
IVisualElementScheduledItem m_EyeDropperScheduler;
void OnEyeDropperStart(MouseDownEvent e)
{
if (EyeDropper.IsOpened)
{
return;
}

this.m_InitialColor = m_Value;
EyeDropper.Start(OnGammaColorChanged);
m_EyeDropperScheduler = this.schedule.Execute(OnEyeDropperMove).Every(10).StartingIn(10);
m_EyeDropper.UnregisterCallback<MouseDownEvent>(OnEyeDropperStart);
m_EyeDropperScheduler = this.schedule.Execute(OnEyeDropperMove).Every(10).StartingIn(10).Until(this.ShouldStopWatchingEyeDropper);
}

private bool ShouldStopWatchingEyeDropper()
{
if (EyeDropper.IsOpened)
{
return false;
}

if (EyeDropper.IsCancelled)
{
SetValue(m_InitialColor);
}
return true;
}

void OnEyeDropperMove(TimerState state)
Expand All @@ -151,7 +171,7 @@ void OnEyeDropperMove(TimerState state)
}
}

VisualElement m_EyeDropper;
readonly VisualElement m_EyeDropper;

public VFXColorField(string label) : base(label)
{
Expand Down Expand Up @@ -184,7 +204,6 @@ void OnColorChanged(Color color)
{
m_EyeDropperScheduler.Pause();
m_EyeDropperScheduler = null;
m_EyeDropper.RegisterCallback<MouseDownEvent>(OnEyeDropperStart);
}

if (OnValueChanged != null)
Expand Down