2023-04-11 05:58:47 +02:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using TMPro;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
using UnityEngine.SceneManagement;
|
|
|
|
|
|
|
|
public class MainMenuManager : MonoBehaviour
|
|
|
|
{
|
|
|
|
private string component = "_FaceDilate";
|
|
|
|
[SerializeField]
|
|
|
|
private TMP_Text title;
|
|
|
|
[SerializeField]
|
|
|
|
private List<TMP_Text> textList= new List<TMP_Text>();
|
|
|
|
private List<float> initDilates= new List<float>();
|
|
|
|
private List<float> dilates= new List<float>();
|
|
|
|
private float dilate = -1;
|
|
|
|
private float initDilate;
|
|
|
|
[SerializeField]
|
|
|
|
float dilateSpeed = 0.1f;
|
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
//initDilate = title.fontSharedMaterials[0].GetFloat(component);
|
|
|
|
initDilate = title.fontMaterials[0].GetFloat(component);
|
2023-04-22 09:18:21 +02:00
|
|
|
|
2023-04-11 05:58:47 +02:00
|
|
|
|
|
|
|
foreach(TMP_Text text in this.textList)
|
|
|
|
{
|
|
|
|
this.initDilates.Add(text.fontMaterials[0].GetFloat(component));
|
|
|
|
this.dilates.Add(-1f);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
this.textList[0].GetComponent<Button>().onClick.AddListener(LoadFirstLevel);
|
|
|
|
this.textList[2].GetComponent<Button>().onClick.AddListener(ExitApp);
|
2023-04-22 09:18:21 +02:00
|
|
|
|
2023-04-11 05:58:47 +02:00
|
|
|
}
|
|
|
|
void LoadFirstLevel()
|
|
|
|
{
|
|
|
|
SceneManager.LoadScene(1);
|
|
|
|
}
|
|
|
|
void ExitApp()
|
|
|
|
{
|
|
|
|
Application.Quit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
//dilate = Mathf.Min(initDilate, dilate += Time.deltaTime);
|
|
|
|
dilate = Mathf.Lerp(dilate, initDilate, Time.deltaTime*dilateSpeed);
|
|
|
|
title.fontMaterials[0].SetFloat(component, dilate);
|
|
|
|
for(int i =0;i<this.textList.Count;i++)
|
|
|
|
{
|
|
|
|
|
|
|
|
dilates[i] = Mathf.Lerp(dilates[i], initDilates[i],Time.deltaTime*dilateSpeed);
|
|
|
|
textList[i].fontMaterials[0].SetFloat(component, dilates[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|