A reusable component with a self-contained UI for rebinding a single action. Slightly retooled from Unity's RebindUI Sample.
Inheritance: MonoBehaviour
Example #1
0
        protected void OnUpdateBindingDisplay(RebindActionUI component, string bindingDisplayString, string deviceLayoutName, string controlPath)
        {
            if (string.IsNullOrEmpty(deviceLayoutName) || string.IsNullOrEmpty(controlPath))
            {
                return;
            }

            var icon = default(Sprite);

            if (InputSystem.IsFirstLayoutBasedOnSecond(deviceLayoutName, "DualShockGamepad"))
            {
                icon = ps4.GetSprite(controlPath);
            }
            else if (InputSystem.IsFirstLayoutBasedOnSecond(deviceLayoutName, "Gamepad"))
            {
                icon = xbox.GetSprite(controlPath);
            }

            var textComponent = component.bindingText;

            // Grab Image component.
            var imageGO        = textComponent.transform.parent.Find("ActionBindingIcon");
            var imageComponent = imageGO.GetComponent <Image>();

            if (icon != null)
            {
                textComponent.gameObject.SetActive(false);
                imageComponent.sprite = icon;
                imageComponent.gameObject.SetActive(true);
            }
            else
            {
                textComponent.gameObject.SetActive(true);
                imageComponent.gameObject.SetActive(false);
            }
        }
Example #2
0
 // Update is called once per frame
 public void RebindingEventStart(RebindActionUI component, InputActionRebindingExtensions.RebindingOperation rebindingOperation)
 {
     Debug.Log("RebindingEventStart");
 }