Example #1
0
    string GetSourceString(InputControlDescriptor source)
    {
        ControlScheme scheme     = m_ActionMapEditCopy.controlSchemes[selectedScheme];
        var           deviceSlot = scheme.GetDeviceSlot(source.deviceKey);

        return(string.Format("{0} {1} {2}", InputDeviceUtility.GetDeviceNameWithTag(deviceSlot), GetDeviceInstanceString(scheme, deviceSlot), InputDeviceUtility.GetDeviceControlName(deviceSlot, source)));
    }
Example #2
0
    void DrawSourceSummary(Rect rect, string label, InputControlDescriptor source)
    {
        if (m_SelectedSource == source)
        {
            GUI.DrawTexture(rect, EditorGUIUtility.whiteTexture);
        }

        rect       = EditorGUI.PrefixLabel(rect, new GUIContent(label));
        rect.width = (rect.width - 4) * 0.5f;

        int indentLevel = EditorGUI.indentLevel;

        EditorGUI.indentLevel = 0;

        var scheme      = m_ActionMapEditCopy.controlSchemes[selectedScheme];
        var deviceSlots = scheme.deviceSlots;

        string[] deviceNames = deviceSlots.Select(slot =>
        {
            if (slot.type == null)
            {
                return(string.Empty);
            }

            return(string.Format("{0} {1}", InputDeviceUtility.GetDeviceNameWithTag(slot), GetDeviceInstanceString(scheme, slot)));
        }).ToArray();

        EditorGUI.BeginChangeCheck();
        int deviceIndex = EditorGUI.Popup(rect, deviceSlots.FindIndex(slot =>
        {
            return(source != null && source.deviceKey != DeviceSlot.kInvalidKey && slot.key == source.deviceKey);
        }), deviceNames);

        if (EditorGUI.EndChangeCheck())
        {
            source.deviceKey = deviceSlots[deviceIndex].key;
        }

        rect.x += rect.width + 4;

        var deviceSlot = scheme.GetDeviceSlot(source.deviceKey);

        string[] controlNames = InputDeviceUtility.GetDeviceControlNames(deviceSlot != null ? deviceSlot.type : null);
        EditorGUI.BeginChangeCheck();
        int controlIndex = EditorGUI.Popup(rect, source.controlIndex, controlNames);

        if (EditorGUI.EndChangeCheck())
        {
            source.controlIndex = controlIndex;
        }

        EditorGUI.indentLevel = indentLevel;
    }
Example #3
0
    void DrawButtonAxisSourceSummary(Rect rect, ButtonAxisSource source)
    {
        ControlScheme scheme             = m_ActionMapEditCopy.controlSchemes[selectedScheme];
        var           negativeDeviceSlot = scheme.GetDeviceSlot(source.negative.deviceKey);
        var           positiveDeviceSlot = scheme.GetDeviceSlot(source.positive.deviceKey);

        if ((Type)(negativeDeviceSlot.type) == (Type)(positiveDeviceSlot.type))
        {
            EditorGUI.LabelField(rect,
                                 string.Format("{0} {1} {2} & {3}",
                                               InputDeviceUtility.GetDeviceNameWithTag(negativeDeviceSlot),
                                               GetDeviceInstanceString(scheme, negativeDeviceSlot),
                                               InputDeviceUtility.GetDeviceControlName(negativeDeviceSlot, source.negative),
                                               InputDeviceUtility.GetDeviceControlName(positiveDeviceSlot, source.positive)
                                               )
                                 );
        }
        else
        {
            EditorGUI.LabelField(rect, string.Format("{0} & {1}", GetSourceString(source.negative), GetSourceString(source.positive)));
        }
    }