2021-08-26 22:36:18 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.InputSystem;
|
|
|
|
|
|
|
|
|
|
|
|
[CreateAssetMenu(fileName = "Device Configurator", menuName = "Scriptable Objects/Device Configurator", order = 1)]
|
|
|
|
|
|
public class DeviceConfigurator : ScriptableObject
|
|
|
|
|
|
{
|
2022-09-19 21:13:23 +03:00
|
|
|
|
[System.Serializable]
|
|
|
|
|
|
public struct DeviceSet
|
|
|
|
|
|
{
|
|
|
|
|
|
public string deviceRawPath;
|
|
|
|
|
|
public DeviceSettings deviceDisplaySettings;
|
|
|
|
|
|
}
|
2021-08-26 22:36:18 +02:00
|
|
|
|
|
2022-09-19 21:13:23 +03:00
|
|
|
|
[System.Serializable]
|
|
|
|
|
|
public struct DisconnectedSettings
|
|
|
|
|
|
{
|
|
|
|
|
|
public string disconnectedDisplayName;
|
|
|
|
|
|
public Color disconnectedDisplayColor;
|
|
|
|
|
|
}
|
2021-08-26 22:36:18 +02:00
|
|
|
|
|
2022-09-19 21:13:23 +03:00
|
|
|
|
public List<DeviceSet> listDeviceSets = new List<DeviceSet>();
|
2021-08-26 22:36:18 +02:00
|
|
|
|
|
2022-09-19 21:13:23 +03:00
|
|
|
|
public DisconnectedSettings disconnectedDeviceSettings;
|
2021-08-26 22:36:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
2022-09-19 21:13:23 +03:00
|
|
|
|
public Sprite GetDeviceBindingIcon(PlayerInput playerInput, string playerInputDeviceInputBinding)
|
|
|
|
|
|
{
|
|
|
|
|
|
string currentDeviceRawPath = playerInput.devices[0].ToString();
|
|
|
|
|
|
Sprite displaySpriteIcon = null;
|
|
|
|
|
|
for (int i = 0; i < listDeviceSets.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (listDeviceSets[i].deviceRawPath.Equals(currentDeviceRawPath))
|
|
|
|
|
|
{
|
|
|
|
|
|
displaySpriteIcon = FilterForDeviceInputBinding(listDeviceSets[i], playerInputDeviceInputBinding);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return displaySpriteIcon;
|
|
|
|
|
|
}
|
2021-08-26 22:36:18 +02:00
|
|
|
|
|
2022-09-19 21:13:23 +03:00
|
|
|
|
private Sprite FilterForDeviceInputBinding(DeviceSet targetDeviceSet, string inputBinding)
|
|
|
|
|
|
{
|
|
|
|
|
|
Sprite spriteIcon = null;
|
|
|
|
|
|
for (int i = 0; i < targetDeviceSet.deviceDisplaySettings.promptIcons.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (targetDeviceSet.deviceDisplaySettings.promptIcons[i].customInputContextString == inputBinding)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (targetDeviceSet.deviceDisplaySettings.promptIcons[i].customInputContextIcon != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
spriteIcon = targetDeviceSet.deviceDisplaySettings.promptIcons[i].customInputContextIcon;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return spriteIcon;
|
|
|
|
|
|
}
|
2021-08-26 22:36:18 +02:00
|
|
|
|
}
|