37 lines
829 B
C#
37 lines
829 B
C#
using BitStrap;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
public class ButtonDeselectFix : MonoBehaviour
|
|
{
|
|
private Navigation navigationNone = default(Navigation);
|
|
|
|
private Navigation navigationTemp = default(Navigation);
|
|
|
|
private Button button;
|
|
|
|
private void Awake()
|
|
{
|
|
navigationNone.mode = Navigation.Mode.None;
|
|
button = GetComponent<Button>();
|
|
if ((bool)button)
|
|
{
|
|
button.onClick.AddListener(DeselectFix);
|
|
}
|
|
}
|
|
|
|
[Button]
|
|
public void DeselectFix()
|
|
{
|
|
if ((bool)EventSystem.current && (bool)button && Input.GetMouseButtonUp(0))
|
|
{
|
|
EventSystem.current.SetSelectedGameObject(button.gameObject);
|
|
navigationTemp = button.navigation;
|
|
button.navigation = navigationNone;
|
|
EventSystem.current.SetSelectedGameObject(null);
|
|
button.navigation = navigationTemp;
|
|
}
|
|
}
|
|
}
|