update
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using Unity.FPS.Game;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Unity.FPS.UI
|
||||
{
|
||||
public class ToggleGameObjectButton : MonoBehaviour
|
||||
{
|
||||
public GameObject ObjectToToggle;
|
||||
public bool ResetSelectionAfterClick;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (ObjectToToggle.activeSelf && Input.GetButtonDown(GameConstants.k_ButtonNameCancel))
|
||||
{
|
||||
SetGameObjectActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetGameObjectActive(bool active)
|
||||
{
|
||||
ObjectToToggle.SetActive(active);
|
||||
|
||||
if (ResetSelectionAfterClick)
|
||||
EventSystem.current.SetSelectedGameObject(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user