39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
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 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 }
|
||
} |