diff --git a/com.unity.visualeffectgraph/CHANGELOG.md b/com.unity.visualeffectgraph/CHANGELOG.md index 53e1aca590b..564e505fb6f 100644 --- a/com.unity.visualeffectgraph/CHANGELOG.md +++ b/com.unity.visualeffectgraph/CHANGELOG.md @@ -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 diff --git a/com.unity.visualeffectgraph/Editor/Controls/VFXColorField.cs b/com.unity.visualeffectgraph/Editor/Controls/VFXColorField.cs index 6f123a6bc60..744f0270de6 100644 --- a/com.unity.visualeffectgraph/Editor/Controls/VFXColorField.cs +++ b/com.unity.visualeffectgraph/Editor/Controls/VFXColorField.cs @@ -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 { @@ -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(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) @@ -153,7 +173,7 @@ void OnEyeDropperMove(TimerState state) } } - VisualElement m_EyeDropper; + readonly VisualElement m_EyeDropper; public VFXColorField(string label) : base(label) { @@ -186,7 +206,6 @@ void OnColorChanged(Color color) { m_EyeDropperScheduler.Pause(); m_EyeDropperScheduler = null; - m_EyeDropper.RegisterCallback(OnEyeDropperStart); } if (OnValueChanged != null)