Ejemplo n.º 1
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;
    }
Ejemplo n.º 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;

        List <Type> types = m_ActionMapEditCopy.controlSchemes[selectedScheme].deviceTypes.ToList();

        string[] deviceNames = types.Select(e => e == null ? string.Empty : e.Name).ToArray();
        EditorGUI.BeginChangeCheck();
        int deviceIndex = EditorGUI.Popup(rect, types.IndexOf(source.deviceType), deviceNames);

        if (EditorGUI.EndChangeCheck())
        {
            source.deviceType = types[deviceIndex];
        }

        rect.x += rect.width + 4;

        string[] controlNames = InputDeviceUtility.GetDeviceControlNames(source.deviceType);
        EditorGUI.BeginChangeCheck();
        int controlIndex = EditorGUI.Popup(rect, source.controlIndex, controlNames);

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

        EditorGUI.indentLevel = indentLevel;
    }