Exemplo n.º 1
0
        void OnGUI()
        {
            if (m_Device == null)
            {
                if (!InputSystemEditorUtility.inputSystemEnabled)
                {
                    InputSystemEditorUtility.ShowSystemNotEnabledHelpbox();
                    return;
                }

                EditorGUILayout.HelpBox(Styles.notFoundHelpText, MessageType.Warning);
                return;
            }
            if (m_ControlIndexStrings == null || m_ControlIndexStrings.Count != m_Device.controlCount)
            {
                InitControlNames();
            }

            EditorGUILayout.BeginVertical("OL Box", GUILayout.ExpandHeight(false));
            EditorGUILayout.LabelField("Name", m_Device.name);
            EditorGUILayout.LabelField("Profile", m_Device.profile != null ? m_Device.profile.GetType().Name : "");
            EditorGUILayout.LabelField("Connected", m_Device.isConnected.ToString());
            EditorGUILayout.LabelField("Active", m_Device.active.ToString());
            EditorGUILayout.LabelField("Manufacturer", m_Device.manufacturer);
            EditorGUILayout.LabelField("Serial Number", m_Device.serialNumber);
            EditorGUILayout.LabelField("Device Type", m_Device.GetType().Name);
            EditorGUILayout.LabelField("Device Tag Index", m_Device.tagIndex.ToString());
            EditorGUILayout.LabelField("Native Device ID", m_Device.nativeId.ToString());
            EditorGUILayout.EndVertical();

            bool wasActive = InputSystem.isActive;

            InputSystem.isActive = true;

            m_ScrollControls = EditorGUILayout.BeginScrollView(m_ScrollControls);
            int controlCount = m_Device.controlCount;

            EditorGUI.indentLevel += 2;
            for (int i = 0; i < controlCount; i++)
            {
                InputControl control = m_Device.GetControl(i);
                string       str     = ToStringWithDecimals(control.valueObject);
                EditorGUILayout.LabelField(control.name, str);

                Rect rect = GUILayoutUtility.GetLastRect();
                rect.width = 28;
                GUI.Label(rect, m_ControlIndexStrings[i], Styles.labelRightAligned);
            }
            EditorGUI.indentLevel -= 2;
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndScrollView();

            InputSystem.isActive = wasActive;

            GUILayout.BeginHorizontal(EditorStyles.toolbar);
            GUILayout.Label("Events", GUILayout.MinWidth(100));
            Rect toolbarHandle = GUILayoutUtility.GetLastRect();

            Rect searchRect = GUILayoutUtility.GetRect(GUIContent.none, Styles.toolbarSearchField, GUILayout.MinWidth(140));

            if (m_Preview.GetExpanded())
            {
                m_EventSearchString = EditorGUI.TextField(searchRect, m_EventSearchString, Styles.toolbarSearchField);
                if (GUILayout.Button(
                        GUIContent.none,
                        m_EventSearchString == string.Empty ? Styles.toolbarSearchFieldCancelEmpty : Styles.toolbarSearchFieldCancel))
                {
                    m_EventSearchString = string.Empty;
                    EditorGUIUtility.keyboardControl = 0;
                }
            }

            GUILayout.EndHorizontal();

            float height = m_Preview.ResizeHandle(new Rect(toolbarHandle.x, position.y, toolbarHandle.width, position.height), 100, 250, 17);

            if (height > 0)
            {
                ShowEvents(height);
            }
        }
Exemplo n.º 2
0
        void OnGUI()
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            m_ShowMaps         = GUILayout.Toggle(m_ShowMaps, Styles.showMaps, EditorStyles.toolbarButton);
            m_ShowUnrecognized = GUILayout.Toggle(m_ShowUnrecognized, Styles.showUnrecognized, EditorStyles.toolbarButton);
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            if (!InputSystemEditorUtility.inputSystemEnabled)
            {
                EditorGUILayout.Space();
                InputSystemEditorUtility.ShowSystemNotEnabledHelpbox();
                EditorGUILayout.Space();
            }

            if (m_ShowMaps)
            {
                s_PlayerElementWidth = k_DeviceElementWidth * 2 + 4;
            }
            else
            {
                s_PlayerElementWidth = k_DeviceElementWidth;
            }

            var devices             = InputSystem.devices;
            var unrecognizedDevices = InputSystem.unrecognizedDevices;
            var players             = PlayerHandleManager.players;

            s_MaxAssignedDevices = 1;
            foreach (var player in players)
            {
                s_MaxAssignedDevices = Mathf.Max(s_MaxAssignedDevices, player.assignments.Count);
            }

            s_MaxMaps = 1;
            foreach (var player in players)
            {
                s_MaxMaps = Mathf.Max(s_MaxMaps, player.maps.Count);
            }

            m_ScrollPos = EditorGUILayout.BeginScrollView(m_ScrollPos);
            {
                ShowUnassignedDevices(devices);

                if (m_ShowUnrecognized)
                {
                    EditorGUILayout.Space();

                    ShowUnrecognizedDevices(unrecognizedDevices);
                }

                EditorGUILayout.Space();

                ShowGlobalPlayerHandles(devices, players);

                EditorGUILayout.Space();

                ShowPlayerHandles(devices, players);
            }
            DrawDevices(devices);
            EditorGUILayout.EndScrollView();
        }