Initial commit

This commit is contained in:
2026-03-03 00:39:30 +05:00
commit fc01f07d9b
29933 changed files with 5353098 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
using UnityEngine.EventSystems;
namespace UnityEngine.InputSystem.Samples.RebindUI
{
/// <summary>
/// Simple utility that modifies a referenced CanvasGroup while being active.
/// </summary>
public class CanvasGroupModifier : MonoBehaviour
{
[Tooltip("The Canvas Group to be modified while this component is active")]
public CanvasGroup canvasGroup;
[Tooltip("The interactable setting to use for the Canvas Group while this component is active")]
public bool interactable = false;
private bool m_SavedInteractable;
private GameObject m_SelectedObject;
private void OnEnable()
{
if (canvasGroup != null)
{
// Store selection to make sure it is not changed when switching "windows".
m_SelectedObject = EventSystem.current.currentSelectedGameObject;
// Save current setting and override
m_SavedInteractable = canvasGroup.interactable;
canvasGroup.interactable = interactable;
}
}
private void OnDisable()
{
if (canvasGroup != null)
{
// Restore previous setting.
canvasGroup.interactable = m_SavedInteractable;
// Restore previous selection.
var eventSystem = EventSystem.current;
if (eventSystem != null)
{
if (m_SelectedObject != null)
eventSystem.SetSelectedGameObject(m_SelectedObject);
else if (EventSystem.current.currentSelectedGameObject == null)
eventSystem.SetSelectedGameObject(eventSystem.firstSelectedGameObject);
}
}
}
}
}