2026-06-03 09:32:20 +03:00

41 lines
1.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using UnityEngine;
public static class In
{
static AbstractInputSource CachedSource;
public static void Initialize(AbstractInputSource inputSource)
{
#if !UNITY_EDITOR
CachedSource = new ComInput();
#else
CachedSource = inputSource;
#endif
//CachedSource = inputSource;
var success = CachedSource.Initialize();
if (!success) Debug.LogWarning("Не удалось проинициалзировать источник управления.");
}
public static void ResetFrameData()
{
CachedSource?.ResetFrameStates();
}
public static bool GetButton(InSignal button) => CachedSource.GetButton(button);
public static bool GetButtonDown(InSignal button) => CachedSource.GetButtonDown(button);
public static bool GetButtonUp(InSignal button) => CachedSource.GetButtonUp(button);
public static bool AnyButton() => CachedSource.AnyButton();
public static AbstractInputSource GetInputSourceByType(InputType type) => type switch
{
InputType.Com => new ComInput(),
_ => new KeyboardInput()
};
public enum InputType { Com, Keyboard }
}