Last active
May 25, 2016 08:22
-
-
Save bilke/05ed33e43cb2cdf5ecbb to your computer and use it in GitHub Desktop.
Slider Bugfix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/Assets/MarkUX/Source/Views/Slider.cs b/Assets/MarkUX/Source/Views/Slider.cs | |
| index c672482..3d8d4dd 100644 | |
| --- a/Assets/MarkUX/Source/Views/Slider.cs | |
| +++ b/Assets/MarkUX/Source/Views/Slider.cs | |
| @@ -1,4 +1,4 @@ | |
| -#region Using Statements | |
| +#region Using Statements | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| @@ -210,19 +210,18 @@ namespace MarkUX.Views | |
| }); | |
| Vector2 pos; | |
| - RectTransformUtility.ScreenPointToLocalPointInRectangle(canvas.transform as RectTransform, mouseScreenPositionIn, canvas.worldCamera, out pos); | |
| - Vector2 mouseScreenPosition = canvas.transform.TransformPoint(pos); | |
| + RectTransformUtility.ScreenPointToLocalPointInRectangle(this.transform as RectTransform, mouseScreenPositionIn, canvas.worldCamera, out pos); | |
| // calculate slide percentage (transform.position.x/y is center of fill area) | |
| float p = 0; | |
| float slideAreaLength = transform.rect.width - SliderHandleLength.Pixels; | |
| if (Orientation == Orientation.Horizontal) | |
| { | |
| - p = ((mouseScreenPosition.x - transform.position.x + slideAreaLength / 2f) / slideAreaLength).Clamp(0, 1); | |
| + p = ((pos.x - transform.localPosition.x + slideAreaLength / 2f) / slideAreaLength).Clamp(0, 1); | |
| } | |
| else | |
| { | |
| - p = ((mouseScreenPosition.y - transform.position.y + slideAreaLength / 2f) / slideAreaLength).Clamp(0, 1); | |
| + p = ((pos.y - transform.localPosition.y + slideAreaLength / 2f) / slideAreaLength).Clamp(0, 1); | |
| } | |
| // set value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment