TO SQUASH: main menu progress.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class MenuButton : MonoBehaviour
|
||||
{
|
||||
public bool isButtonPressed = false;
|
||||
|
||||
public Animator keyAnimator;
|
||||
|
||||
private SpriteRenderer spriteRenderer;
|
||||
|
||||
private Collider2D boxCollider;
|
||||
|
||||
private static Color transparent = new Color(1f, 1f, 1f, 0f);
|
||||
|
||||
private static Color opaque = new Color(1f, 1f, 1f, 1f);
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
spriteRenderer = GetComponent<SpriteRenderer>();
|
||||
boxCollider = GetComponent<Collider2D>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Mouse.current.leftButton.wasPressedThisFrame)
|
||||
{
|
||||
Vector2 mousePosition = Mouse.current.position.ReadValue();
|
||||
Vector2 worldMousePosition = Camera.main.ScreenToWorldPoint(mousePosition);
|
||||
|
||||
if (boxCollider.OverlapPoint(worldMousePosition))
|
||||
{
|
||||
isButtonPressed = true;
|
||||
keyAnimator.SetTrigger("buttonChanged");
|
||||
} else {
|
||||
isButtonPressed = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isButtonPressed)
|
||||
{
|
||||
spriteRenderer.color = opaque;
|
||||
}
|
||||
else
|
||||
{
|
||||
spriteRenderer.color = transparent;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2a38d9207cd188e1ab773fd8bce07b5d
|
||||
@@ -0,0 +1,35 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class MenuKey : MonoBehaviour
|
||||
{
|
||||
public AudioClip keyTurnOpen;
|
||||
|
||||
public AudioClip keyTurnClose;
|
||||
|
||||
private AudioSource audioSource;
|
||||
|
||||
private Animator animator;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
audioSource = GetComponent<AudioSource>();
|
||||
animator = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void playKeyTurnOpen(int _)
|
||||
{
|
||||
audioSource.PlayOneShot(keyTurnOpen);
|
||||
}
|
||||
|
||||
public void playKeyTurnClose(int _)
|
||||
{
|
||||
audioSource.PlayOneShot(keyTurnClose);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 70493513b2ac454ad8e5943a33f983fe
|
||||
Reference in New Issue
Block a user