campfire/Assets/Scripts/TutorialController.cs

31 lines
803 B
C#
Raw Normal View History

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