public void Update() { TypeScrollDirection direction; if (moveTrigger == true) { direction = moveDirection; } else { direction = moveSmoothDirection; } float direction_sign = 1.0f; switch (direction) { case TypeScrollDirection.RightToLeft: direction_sign *= -1.0f; break; case TypeScrollDirection.LeftToRight: break; } float speed = scrollBaseSpeed * direction_sign * (smoothElapsedTime / smoothDurationTime); for (int i = 0; i < scrollObjects.Count; ++i) { scrollObjects[i].ScrollUpdate(speed); } if (moveTrigger == true) { smoothElapsedTime += Time.deltaTime; } else { smoothElapsedTime -= Time.deltaTime; } smoothElapsedTime = Mathf.Clamp(smoothElapsedTime, 0.0f, smoothDurationTime); moveTrigger = false; moveDirection = TypeScrollDirection.None; }
public void ScrollUpdate(TypeScrollDirection direction) { moveDirection = direction; moveSmoothDirection = direction; moveTrigger = true; }