using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using static UnityEngine.Rendering.DebugUI.Table; public class Controller : MonoBehaviour { public Transform Left; public Transform Center; public Transform Right; public Transform Temp; public Transform Next; public Transform[] Models; public int index = 0; public Button LeftButton; public Button RightButton; private Transform Rot; void Start() { Rot = Temp; } public void CutRight() { RightButton.interactable = false; index += 1; Rot = null; if (index >= 0) { Next = Models[index % Models.Length]; } else { Next = Models[Models.Length + (index % Models.Length == 0 ? -3 : index % Models.Length)]; } StartCoroutine(RightMove()); } public void CutLeft() { LeftButton.interactable = false; index -= 1; Rot = null; if (index >= 0) { Next = Models[index % Models.Length]; } else { Next = Models[Models.Length + (index % Models.Length == 0 ? -3 : index % Models.Length)]; } StartCoroutine(LeftMove()); } IEnumerator LeftMove() { float time = 0; while (time < 1) { time += Time.deltaTime; Next.position = Vector3.Lerp(Right.position, Center.position, time); Temp.position = Vector3.Lerp(Center.position, Left.position, time); yield return 0; } Temp = Rot = Next; LeftButton.interactable = true; } IEnumerator RightMove() { float time = 0; while (time < 1) { time += Time.deltaTime; Next.position = Vector3.Lerp(Left.position, Center.position, time); Temp.position = Vector3.Lerp(Center.position, Right.position, time); yield return 0; } Temp = Rot = Next; RightButton.interactable = true; } void Update() { if (Rot) { if (Input.GetMouseButton(0)) { Rot.rotation = Quaternion.Euler(Rot.rotation.eulerAngles + new Vector3(0, -Input.GetAxis("Mouse X") * Time.deltaTime * 500, 0)); } else { Rot.RotateAround(Rot.position, Vector3.up, Time.deltaTime * 25); } Rot.localScale += (Rot.localScale + Vector3.one * Input.GetAxis("Mouse ScrollWheel")).x < 0 ? Vector3.zero : (Vector3.one * Input.GetAxis("Mouse ScrollWheel")); } } }