44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
|
|
public class GunsMenu : MonoBehaviour
|
|
{
|
|
public GameObject Buttons;
|
|
public GameObject[] Guns;
|
|
int currentGun = 0;
|
|
void Start()
|
|
{
|
|
Guns[0].SetActive(true);
|
|
}
|
|
|
|
public void NextGun()
|
|
{
|
|
Guns[currentGun ].SetActive(false);
|
|
currentGun++;
|
|
if (currentGun >= Guns.Length)
|
|
currentGun = 0;
|
|
Guns[currentGun].SetActive(true);
|
|
}
|
|
public void PreviousGun()
|
|
{
|
|
Guns[currentGun].SetActive(false);
|
|
currentGun--;
|
|
if (currentGun < 0)
|
|
currentGun = Guns.Length - 1;
|
|
Guns[currentGun].SetActive(true);
|
|
}
|
|
private void Update()
|
|
{
|
|
if ((Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject()) || (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began && !EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId)))
|
|
{
|
|
Buttons.SetActive(false);
|
|
}
|
|
else if(Input.touchCount == 0 && !Input.GetMouseButton(0))
|
|
{
|
|
Buttons.SetActive(true);
|
|
}
|
|
}
|
|
}
|