1
NGUI 3 Support / Re: UIPopupList closes immediately at low frame-rates (PC).
« on: January 16, 2015, 10:16:42 PM »
Couple hours of debugging under my belt, here are my findings:
Forcing unity to run at a target frame-rate of 5 frames. Long story short, we seem to run into an unexpected case in UICamera's ProcessMouse() function where Intput.GetMouseButtonDown and Input.GetMouseButtonUp are both evaluated true in the same frame. I'm not sure if this is a normal case, or even an edge case at a normal frame-rate.
The logic in ProcessTouch handles both pressed and unpressed inclusively. The logic for pressed starts a coroutine, but the logic for unpressed runs before that coroutine can continue, so (seemingly) the mSelectedObject and mNextSelection objects are garbage values by the time the coroutine has time to deal with them. And thus, the coroutine closes the popuplist at the end of the frame.
My current fix is simply to make unpressed always evaluate to false if pressed is true. However, I'm not sure if this is a good idea. It does cause the popups to work fine at the low framerate, and I wasn't able to find anything else that breaks due to the change (though I only tested briefly).
What do you think?
The code in UICamera's ProcessMouse() function, with my edit noted:
Forcing unity to run at a target frame-rate of 5 frames. Long story short, we seem to run into an unexpected case in UICamera's ProcessMouse() function where Intput.GetMouseButtonDown and Input.GetMouseButtonUp are both evaluated true in the same frame. I'm not sure if this is a normal case, or even an edge case at a normal frame-rate.
The logic in ProcessTouch handles both pressed and unpressed inclusively. The logic for pressed starts a coroutine, but the logic for unpressed runs before that coroutine can continue, so (seemingly) the mSelectedObject and mNextSelection objects are garbage values by the time the coroutine has time to deal with them. And thus, the coroutine closes the popuplist at the end of the frame.
My current fix is simply to make unpressed always evaluate to false if pressed is true. However, I'm not sure if this is a good idea. It does cause the popups to work fine at the low framerate, and I wasn't able to find anything else that breaks due to the change (though I only tested briefly).
What do you think?
The code in UICamera's ProcessMouse() function, with my edit noted:
- // Process all 3 mouse buttons as individual touches
- for (int i = 0; i < 3; ++i)
- {
- bool pressed = Input.GetMouseButtonDown(i);
- bool unpressed = Input.GetMouseButtonUp(i);
- if (pressed) unpressed = false; // CHARLIE'S (PROBABLY TERRIBLE) EDIT.
- if (pressed || unpressed) currentScheme = ControlScheme.Mouse;
- ... snip ...
- // Process the mouse events
- ProcessTouch(pressed, unpressed);
- currentKey = KeyCode.None;
- }