Files
UltimateFishing2020/Assets/Scripts/Assembly-CSharp/Rewired/Demos/ControlMapperDemoMessage.cs
2026-03-04 10:03:45 +08:00

56 lines
1.1 KiB
C#

using System.Collections;
using Rewired.UI.ControlMapper;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace Rewired.Demos
{
[AddComponentMenu("")]
public class ControlMapperDemoMessage : MonoBehaviour
{
public ControlMapper controlMapper;
public Selectable defaultSelectable;
private void Awake()
{
if (controlMapper != null)
{
controlMapper.ScreenClosedEvent += OnControlMapperClosed;
controlMapper.ScreenOpenedEvent += OnControlMapperOpened;
}
}
private void Start()
{
SelectDefault();
}
private void OnControlMapperClosed()
{
base.gameObject.SetActive(value: true);
StartCoroutine(SelectDefaultDeferred());
}
private void OnControlMapperOpened()
{
base.gameObject.SetActive(value: false);
}
private void SelectDefault()
{
if (!(EventSystem.current == null) && defaultSelectable != null)
{
EventSystem.current.SetSelectedGameObject(defaultSelectable.gameObject);
}
}
private IEnumerator SelectDefaultDeferred()
{
yield return null;
SelectDefault();
}
}
}