You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CrowdControl/Assets/Feel/MMTools/Tools/MMGUI/MMGetFocusOnEnable.cs

20 lines
501 B
C#

3 months ago
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using MoreMountains.Tools;
using UnityEngine.EventSystems;
namespace MoreMountains.Tools
{
/// <summary>
/// Add this helper to an object and focus will be set to it on Enable
/// </summary>
[AddComponentMenu("More Mountains/Tools/GUI/MMGetFocusOnEnable")]
public class MMGetFocusOnEnable : MonoBehaviour
{
protected virtual void OnEnable()
{
EventSystem.current.SetSelectedGameObject(this.gameObject, null);
}
}
}