39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class InputProviderManager : MonoBehaviour
|
|
{
|
|
private static InputProviderManager instance;
|
|
private BaseInputProvider currentInputProvider;
|
|
|
|
private void Awake()
|
|
{
|
|
if (instance == null) instance = this;
|
|
else Destroy(this.gameObject);
|
|
|
|
// check the current platform and determine which Provider to use
|
|
currentInputProvider = Application.isMobilePlatform ?
|
|
gameObject.GetComponentInChildren<MobileInputProvider>() :
|
|
gameObject.GetComponentInChildren<PCIntputProvider>();
|
|
|
|
// disable all InputProviders
|
|
BaseInputProvider[] inputProviders = GetComponentsInChildren<BaseInputProvider>();
|
|
foreach (BaseInputProvider inputProvider in inputProviders)
|
|
inputProvider.Disable();
|
|
|
|
currentInputProvider.Enable();
|
|
}
|
|
|
|
public static InputProviderManager getInstance()
|
|
{
|
|
return instance;
|
|
}
|
|
|
|
public BaseInputProvider getCurrentInputProvider()
|
|
{
|
|
return currentInputProvider;
|
|
}
|
|
|
|
}
|