void Update() { if (inputModule != null && selectables != null) { float horizontal = inputModule.GetAxis(NeverdawnInputAxis.HorizontalLeft); float vertical = inputModule.GetAxis(NeverdawnInputAxis.VerticalLeft); if (inputModule.GetButtonDown(NeverdawnInputButton.Left)) { selectTop(); } if (inputModule.GetButtonDown(NeverdawnInputButton.Right)) { selectBottom(); } if (horizontal > 0.0f && prevHorizontal == 0.0f && Mathf.Abs(horizontal) > Mathf.Abs(vertical)) { selectBottom(); } if (horizontal < 0.0f && prevHorizontal == 0.0f && Mathf.Abs(horizontal) > Mathf.Abs(vertical)) { selectTop(); } if (vertical > 0.0f && prevVertical == 0.0f && Mathf.Abs(horizontal) < Mathf.Abs(vertical)) { selectTop(); } if (vertical < 0.0f && prevVertical == 0.0f && Mathf.Abs(horizontal) < Mathf.Abs(vertical)) { selectBottom(); } prevHorizontal = horizontal; prevVertical = vertical; } if (lerp <= 1.0f) { lerp += Time.deltaTime * scrollSpeed; rectTransform.anchoredPosition = new Vector2(0.0f, Mathf.Lerp(currentScroll, targetScroll, lerp)); } }
// Update is called once per frame void Update() { if (inputModule != null) { float horizontal = inputModule.GetAxis(NeverdawnInputAxis.HorizontalLeft); float vertical = inputModule.GetAxis(NeverdawnInputAxis.VerticalLeft); Vector3 input = inputModule.normalizedDirection; if (input.sqrMagnitude < 0.1f) { if (center != null) { center.Select(); } else if (selected != null) { selected.Deselect(); } selected = null; } if (input.sqrMagnitude > 0.1f) { float inputAngle = Vector3.SignedAngle(Vector3.forward, input, Vector3.up); if (inputAngle < 0.0f) { inputAngle = 360.0f + inputAngle; } inputAngle += angle / 2.0f; int index = NeverdawnUtility.RepeatIndex((int)(inputAngle / angle), peripherals.Length); selected = peripherals[index]; peripherals[index].Select(); } previousInput = input; } }