Skip to content

[VFX] Revert "Color field keeps updating when using eye dropper and Esc key is pressed" #5122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion com.unity.visualeffectgraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fix unexpected Spawn context execution ordering
- Fix incorrect buffer type for strips
- Enabled an optimization for motion vectors, storing projected positions for vertices instead of the transform matrix
- Eye dropper in the color fields kept updating after pressing the Esc key
- Sticky notes can now be deleted through contextual manual menu
- Blackboard fields can now be duplicated either with a shortcut (Ctrl+D) or with a contextual menu option
- Properties labels do not overlap anymore
Expand Down
29 changes: 5 additions & 24 deletions com.unity.visualeffectgraph/Editor/Controls/VFXColorField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ VisualElement CreateColorContainer()
return m_Container;
}

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

public bool showAlpha
{
Expand Down Expand Up @@ -138,28 +137,9 @@ 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).Until(this.ShouldStopWatchingEyeDropper);
}

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

if (EyeDropper.IsCancelled)
{
SetValue(m_InitialColor);
}
return true;
m_EyeDropperScheduler = this.schedule.Execute(OnEyeDropperMove).Every(10).StartingIn(10);
m_EyeDropper.UnregisterCallback<MouseDownEvent>(OnEyeDropperStart);
}

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

readonly VisualElement m_EyeDropper;
VisualElement m_EyeDropper;

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

if (OnValueChanged != null)
Expand Down