57 lines
1.6 KiB
C#
57 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
[CreateAssetMenu(menuName = "Thomas09/ReplacementConfig")]
|
|
public class UI_IconsConfig : ScriptableObject
|
|
{
|
|
|
|
[System.Serializable]
|
|
class Replacement
|
|
{
|
|
public string Id = null;
|
|
public string Value = null;
|
|
public string PSValue = null;
|
|
public InputActionReference ActionReference;
|
|
}
|
|
|
|
[SerializeField] Replacement[] replacements = default;
|
|
|
|
public string Replace(string id)
|
|
{
|
|
foreach (Replacement replacement in replacements)
|
|
{
|
|
if (replacement.Id == id)
|
|
{
|
|
InputHandler inputHandler = Player.Instance.GetInputHandler();
|
|
|
|
if (inputHandler.UsingGamePad)
|
|
{
|
|
if (inputHandler.IsXboxController)
|
|
{
|
|
return replacement.Value;
|
|
}
|
|
else
|
|
{
|
|
return replacement.PSValue;
|
|
}
|
|
}
|
|
else if(replacement.ActionReference != null)
|
|
{
|
|
string displayedString = $"<color=#FF7600><b>{replacement.ActionReference.action.GetBindingDisplayString()}</b></color>";
|
|
return displayedString;
|
|
}
|
|
else
|
|
{
|
|
return "<color=#FF7600>"+replacement.Value+"</color>";
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
Debug.LogError($"No replacement found for {id}", this);
|
|
return "?";
|
|
}
|
|
}
|