UI/UX Polish and improvements
This commit is contained in:
64
Assets/Scripts/UI/MainMenu.cs
Normal file
64
Assets/Scripts/UI/MainMenu.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MainMenu : MonoBehaviour
|
||||
{
|
||||
public float transitionTime = 1f;
|
||||
private float counter, introCounter = 0;
|
||||
public bool transition, introTransition = false;
|
||||
public GameObject transitionPanel;
|
||||
public GameObject introTransitionPanel;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
introTransition = true;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(transition)
|
||||
{
|
||||
counter += Time.deltaTime;
|
||||
Color c = transitionPanel.GetComponent<Image>().color;
|
||||
c.a = Mathf.Lerp(0f, 1f, counter / transitionTime);
|
||||
transitionPanel.GetComponent<Image>().color = c;
|
||||
}
|
||||
|
||||
if (counter >= transitionTime){
|
||||
SceneManager.LoadScene("Main");
|
||||
}
|
||||
|
||||
if (introTransition)
|
||||
{
|
||||
introCounter += Time.deltaTime;
|
||||
Color c = introTransitionPanel.GetComponent<Image>().color;
|
||||
c.a = Mathf.Lerp(1f, 0f, introCounter / transitionTime);
|
||||
introTransitionPanel.GetComponent<Image>().color = c;
|
||||
}
|
||||
|
||||
if (introCounter >= transitionTime)
|
||||
{
|
||||
Destroy(introTransitionPanel);
|
||||
}
|
||||
}
|
||||
|
||||
public void Quit()
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
public void OpenKbxLink()
|
||||
{
|
||||
Application.OpenURL("https://kittenbox.games");
|
||||
}
|
||||
|
||||
public void StartGame()
|
||||
{
|
||||
transitionPanel.SetActive(true);
|
||||
transition = true;
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/MainMenu.cs.meta
Normal file
2
Assets/Scripts/UI/MainMenu.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dcb1dd097d5b77c4a88729ee92b6bfdf
|
||||
38
Assets/Scripts/UI/MousePosLabel.cs
Normal file
38
Assets/Scripts/UI/MousePosLabel.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MousePosLabel : MonoBehaviour
|
||||
{
|
||||
public Vector3 direction = new Vector3(0,1,0);
|
||||
public float floatSpeed = 20f;
|
||||
public float lifetime = 5f;
|
||||
private float counter = 0;
|
||||
public TMPro.TMP_Text tmp;
|
||||
// Start is called before the first frame update
|
||||
void Awake()
|
||||
{
|
||||
tmp = GetComponent<TMPro.TMP_Text>();
|
||||
transform.position = Input.mousePosition;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
transform.position = transform.position + direction * floatSpeed * Time.deltaTime;
|
||||
counter += Time.deltaTime;
|
||||
|
||||
if( counter > lifetime/2)
|
||||
{
|
||||
Color32 c = new Color32((byte)tmp.color.r, (byte)tmp.color.g, (byte)tmp.color.b, (byte)tmp.color.a);
|
||||
c.a = (byte)Mathf.Lerp(255f, 0f, (counter-(lifetime/2)) / (lifetime/2));
|
||||
tmp.color = c;
|
||||
tmp.SetAllDirty();
|
||||
}
|
||||
|
||||
if (counter >= lifetime)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/MousePosLabel.cs.meta
Normal file
2
Assets/Scripts/UI/MousePosLabel.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1822090174f4dd34ca9c4f0c5533b22e
|
||||
@@ -1,18 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
public class WorldMapUI : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f5605aef187419469548c23842f08da
|
||||
Reference in New Issue
Block a user