GeoJam2021/Assets/Scripts/MenuPlay.cs

45 lines
1.2 KiB
C#
Raw Normal View History

2021-07-22 20:09:52 +02:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class MenuPlay : MonoBehaviour
{
public LayerMask contactFilter;
2021-07-22 21:52:18 +02:00
public AudioSource sfx;
2021-07-22 20:09:52 +02:00
public MenuMouse mouse;
2021-07-23 17:00:30 +02:00
public SpriteRenderer sr;
private bool hover = false;
private bool previous_hover = false;
2021-07-22 20:09:52 +02:00
// Start is called before the first frame update
void Start()
{
Cursor.visible = false;
}
// Update is called once per frame
void Update()
{
2021-07-23 17:00:30 +02:00
if(Physics2D.CircleCast(mouse.pos, 1f, Vector2.zero, 0f, contactFilter)){
if (Input.GetMouseButtonDown(0)){
2021-07-22 21:52:18 +02:00
sfx.Play();
2021-07-24 12:38:43 +02:00
SceneManager.LoadScene("Intro");
2021-07-22 20:09:52 +02:00
}
2021-07-23 17:00:30 +02:00
previous_hover = hover;
hover = true;
} else {
previous_hover = hover;
hover = false;
}
if (hover != previous_hover) {
if(hover) {
sr.color = new Color(202f / 255f, 202f / 255f, 242f / 255f, 201f / 255f);
} else {
sr.color = new Color(149f / 255f, 189f / 255f, 253f / 255f, 201f / 255f);
}
2021-07-22 20:09:52 +02:00
}
}
}