浏览代码

refine scroll : a scroll activity lasts for 0.3 seconds instead of 20 frames.

/main
xingwei.zhu 6 年前
当前提交
bacb0c29
共有 3 个文件被更改,包括 16 次插入16 次删除
  1. 2
      Runtime/editor/editor_window.cs
  2. 28
      Runtime/editor/scroll_input.cs
  3. 2
      Runtime/engine/UIWidgetsPanel.cs

2
Runtime/editor/editor_window.cs


}
void _updateScrollInput() {
var deltaScroll = this._scrollInput.getScrollDelta();
var deltaScroll = this._scrollInput.getScrollDelta(Time.deltaTime);
if (deltaScroll == Vector2.zero) {
return;

28
Runtime/editor/scroll_input.cs


namespace Unity.UIWidgets.editor {
public class ScrollInput {
readonly int _bufferSize = 20;
readonly float _scrollScale = 10;
readonly float _bufferSize = 20.0f / 60; // a scroll action leads to 20 frames, i.e., ( 20 / 60 ) seconds smoothly-scrolling when fps = 60 (default)
readonly float _scrollScale = 20;
int _bufferIndex;
float _bufferIndex;
float _curDeltaX;
float _curDeltaY;

public ScrollInput(int? bufferSize = null, float? scrollScale = null) {
public ScrollInput(float? bufferSize = null, float? scrollScale = null) {
this._bufferSize = bufferSize ?? this._bufferSize;
this._scrollScale = scrollScale ?? this._scrollScale;

return this._pointerY;
}
public Vector2 getScrollDelta() {
public Vector2 getScrollDelta(float deltaTime) {
if (this._bufferIndex == 0) {
if (this._bufferIndex <= deltaTime) {
deltaScroll.x = this._scrollDeltaX;
deltaScroll.y = this._scrollDeltaY;
this._scrollDeltaX = 0;

deltaScroll.x = this._curDeltaX;
deltaScroll.y = this._curDeltaY;
deltaScroll.x = this._curDeltaX * deltaTime;
deltaScroll.y = this._curDeltaY * deltaTime;
? Mathf.Max(0, this._scrollDeltaX - this._curDeltaX)
: Mathf.Min(0, this._scrollDeltaX - this._curDeltaX);
? Mathf.Max(0, this._scrollDeltaX - this._curDeltaX * deltaTime)
: Mathf.Min(0, this._scrollDeltaX - this._curDeltaX * deltaTime);
? Mathf.Max(0, this._scrollDeltaY - this._curDeltaY)
: Mathf.Min(0, this._scrollDeltaY - this._curDeltaY);
this._bufferIndex--;
? Mathf.Max(0, this._scrollDeltaY - this._curDeltaY * deltaTime)
: Mathf.Min(0, this._scrollDeltaY - this._curDeltaY * deltaTime);
this._bufferIndex -= deltaTime;
return deltaScroll;
}
}

2
Runtime/engine/UIWidgetsPanel.cs


InputUtils.getScrollButtonKey());
}
var deltaScroll = this._scrollInput.getScrollDelta();
var deltaScroll = this._scrollInput.getScrollDelta(Time.deltaTime);
if (deltaScroll != Vector2.zero) {
this._windowAdapter.postPointerEvent(new ScrollData(
timeStamp: Timer.timespanSinceStartup,

正在加载...
取消
保存