using System.Collections; using System.Collections.Generic; using UnityEngine; [RequireComponent(typeof(CanvasGroup))] public class TutorialController : MonoBehaviour { public KeyCode ToggleKey; public bool Toggled = true; public float AnimationLerpFactor = 10f; private RectTransform Rect; private void Awake() { Rect = GetComponent(); } private void Start() { Rect.anchoredPosition = new Vector2(-100, -100); } private void Update() { if (Input.GetKeyDown(ToggleKey)) { Toggled = !Toggled; } Vector2 Pos = Rect.anchoredPosition; Pos.y = Mathf.Lerp(Pos.y, Toggled ? -100 : (Rect.rect.height + 10), AnimationLerpFactor * Time.deltaTime); Rect.anchoredPosition = Pos; } }