Skip to content
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: 1 addition & 0 deletions com.unity.visualeffectgraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Prevent vector truncation error in HDRP Decal template
- Unexpected compilation error while modifying ShaderGraph exposed properties [Case 1361601](https://issuetracker.unity3d.com/product/unity/issues/guid/1361601/)
- Compilation issue while using new SG integration and SampleTexture/SampleMesh [Case 1359391](https://issuetracker.unity3d.com/product/unity/issues/guid/1359391/)
- Eye dropper in the color fields kept updating after pressing the Esc key

## [11.0.0] - 2020-10-21
### Added
Expand Down
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 @@ -94,7 +94,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 @@ -139,9 +140,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 @@ -153,7 +173,7 @@ void OnEyeDropperMove(TimerState state)
}
}

VisualElement m_EyeDropper;
readonly VisualElement m_EyeDropper;

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

if (OnValueChanged != null)
Expand Down