I spent my entire Sunday on this bug. Please believe that it is there and is reproducible! I was able to recreate the bug on both a windows and mac machine using Unity 3.5.1f2 using an old version of NGUI as well as 2.0.3d. I can reproduce it using an NGUI example in a default scene with a default project. If you can give me a place to send it then I can give you this test case. I do not think that is necessary because I can provide the exact steps to reproduce below. Please bear with me. Here are the steps to reproduce the bug (there are two versions of this bug. I will show both):
1. Open New Unity project. Import latest version of NGUI. Open NGUI scene called "Tutorial 7 - Slider".
2. create a new .cs script called "ResetSliderOnRelease"
3. paste these contents into above ResetSliderOnRelease .cs script:
using UnityEngine;
using System.Collections;
public class ResetSliderOnRelease : MonoBehaviour
{
public UISlider theSlider;
float fMiddle = 0.5F;
void OnPress (bool isPressed)
{
float theTime = Time.time;
print ("got message, isPressed is: " + isPressed + " at " + theTime);
if (theSlider != null && isPressed == false)
{
theSlider.sliderValue = fMiddle;
theSlider.ForceUpdate ();
}
}
}
BUG ONE:
1. Place ResetSliderOnRelease.cs on "Slider - Horizontal"
2. Drag game object "Slider - Horizontal" onto "UISlider" slot of "Slider - Horizontal" game object.
3. In UICamera.cs, insert this code on line 863, which is the "if (unpressed){" code block in method "ProcessTouch (bool, bool)"
print ("In UICamera, sending slider is unpressed message at time " + Time.time + "...you should see the slider snap back to the middle immediately...");
4. Press Play in Unity.
5.
Drag the slider and release. Notice the console prints the sent unpressed message in UICamera.
6. Notice there is no print in ResetSliderOnRelease.cs because it has not received the unpressed message that was sent.
8. Wait 10 to 30 seconds. Notice the message is still not received.
7.
Click anywhere on the slider. The slider now snaps back to center.
9. Inspect the prints in the console and notice the OnPressed message was finally received! As well as the second message!
10. Notice how dragging "breaks" the snapping back to center while clicking works fine.
BUG TWO:
1. Press Stop in Unity. Remove ResetSliderOnRelease.cs from "Slider - Horizontal" and place on its child "UISlicedSprite - Thumb".
2. Drag the "UISlicedSprite - Thumb" game object onto the "UISlider" slot of "UISlicedSprite - Thumb".
3. Press Play in Unity.
4. Notice how the bug is now inverted... clicking is "broken" and dragging works fine.
Current Workarounds for bug:
1. Hack into UICamera.cs. Add a custom bool called HACKOnPressToThisGOOnly. If bool is true, send message to gameObject.SendMessage. Apply ResetSliderOnRelease.cs to NGUI Camera game object.
-OR-
2. Place ResetSliderOnRelease.cs on both the slider and thumb.
I would greatly appreciate if you could try to reproduce this bug and fix it!