public void OnGUI()
        {
            EditorGUI.BeginChangeCheck();

            EnsureGUIStyles();

            if ((schemes.Count <= 0) || (IsControlSchemeSelected && selectedControlSchemeIndex >= schemes.Count) || (IsActionSelected && selectedActionIndex >= schemes[selectedControlSchemeIndex].Actions.Count))
            {
                InputManagerWindow.ResetSelections();
            }


            // HierarchyGUI.UpdateHierarchyPanelWidth(InputManagerWindow.tabsOffYOffset);

            // HierarchyGUI.DrawMainPanel(InputManagerWindow.tabsOffYOffset, DrawSelected);

            // if (HierarchyGUI.DrawHierarchyPanel(InputManagerWindow.tabsOffYOffset, true, BuildHierarchyElementsList())) {
            //  ResetKeyFields();
            // }

            if (HierarchyGUI.Draw(InputManagerWindow.tabsOffYOffset, true, BuildHierarchyElementsList(), DrawSelected, CreateFileMenu))
            {
                ResetKeyFields();
            }

            // HierarchyGUI.DrawMainToolbar(CreateFileMenu, InputManagerWindow.tabsOffYOffset);



            if (EditorGUI.EndChangeCheck())
            {
                guiChanged = true;
            }
        }
        void CreateNewControlScheme()
        {
            schemes.Add(new ControlScheme());

            InputManagerWindow.ResetSelections();
            selectedControlSchemeIndex = schemes.Count - 1;
            InputManagerWindow.instance.Repaint();
        }
        public void OnGUI()
        {
            if (gamepadProfiles == null)
            {
                gamepadProfiles = GamepadHandler.LoadAllGamepadProfiles();
            }

            if (gamepadProfiles.Length <= 0 || (hasSelection && selectedProfileIndex >= gamepadProfiles.Length))
            {
                InputManagerWindow.ResetSelections();
            }

            float testButtonHeight = 30;

            if (Application.isPlaying)
            {
                testButtonHeight += 45;
                if (testSceneEditor.lastScene != null)
                {
                    testButtonHeight += 44;
                }
            }

            if (HierarchyGUI.Draw(InputManagerWindow.tabsOffYOffset + testButtonHeight, false, BuildHierarchyElementsList(), DrawSelected, CreateEditMenu))
            {
                OnNewProfileSelection(gamepadProfiles[selectedProfileIndex]);
            }

            Rect testRect = new Rect(0.0f, 0.0f, InputManagerWindow.width, testButtonHeight);

            testRect.y += InputManagerWindow.tabsOffYOffset;

            GUILayout.BeginArea(testRect);

            for (int i = 0; i < 1; i++)
            {
                EditorGUILayout.Space();
            }

            if (Application.isPlaying)
            {
                if (testSceneEditor.lastScene != null)
                {
                    EditorGUILayout.HelpBox("Do not close the Input Manager window while in the gamepad testing scene.\n\nOr you will not be taken back to the original scene you were working on...", MessageType.Warning);
                }
                EditorGUILayout.HelpBox("[Play Mode]: Any new Profiles will be active the next time you enter play mode.", MessageType.Info);
            }
            else
            {
                if (GUILayout.Button("Start Gamepad Inputs Testing Scene"))
                {
                    testSceneEditor.StartTestScene();
                }
            }

            GUILayout.EndArea();
        }
        void OnEnable()
        {
            instance = this;

            hierarchyGUI.OnEnable();
            controlSchemes.OnEnable(hierarchyGUI);
            gamepadProfilesWindow.OnEnable(hierarchyGUI);
            EditorApplication.playModeStateChanged += OnPlayStateChanged;

            ConvertUnityInputManager.ShowStartupWarning();
        }
 void OnEnable()
 {
     instance   = this;
     selections = new Selection[2];
     for (int i = 0; i < 2; i++)
     {
         selections[i] = new Selection();
     }
     ResetSelections();
     ConvertUnityInputManager.ShowStartupWarning();
     controlSchemes.OnEnable();
     EditorApplication.playModeStateChanged += OnPlayStateChanged;
 }
Esempio n. 6
0
        static bool DrawBaseHiearchyItem(Rect position, int index, bool expandable, HieararchyGUIElement element)
        {
            bool clicked = false;

            Rect foldoutRect = new Rect(5.0f, 1.0f, 10, position.height - 1.0f);
            Rect nameRect    = new Rect(expandable ? foldoutRect.xMax + 5.0f : 5.0f, 1.0f, position.width - (expandable ? (foldoutRect.xMax + 5.0f) : 0), position.height - 1.0f);

            if (Event.current.type == EventType.MouseDown && (Event.current.button == 0 || Event.current.button == 1))
            {
                if (position.Contains(Event.current.mousePosition))
                {
                    InputManagerWindow.ResetSelections();
                    InputManagerWindow.SetSelection(0, index);

                    clicked = true;

                    GUI.FocusControl(null);
                    InputManagerWindow.instance.Repaint();

                    if (Event.current.button == 1)
                    {
                        element.createContextMenu(new Rect(Event.current.mousePosition, Vector2.zero));
                    }
                }
            }

            GUI.BeginGroup(position);

            if (InputManagerWindow.GetSelection(0) >= 0 && InputManagerWindow.GetSelection(1) < 0 && InputManagerWindow.GetSelection(0) == index)
            {
                GUI.DrawTexture(new Rect(0, 0, position.width, position.height), m_highlightTexture, ScaleMode.StretchToFill);

                if (expandable)
                {
                    schemesExpanded[index] = !EditorGUI.Foldout(foldoutRect, Expanded(index), GUIContent.none);
                }
                EditorGUI.LabelField(nameRect, element.name, m_whiteLabel);
            }
            else
            {
                if (expandable)
                {
                    schemesExpanded[index] = !EditorGUI.Foldout(foldoutRect, Expanded(index), GUIContent.none);
                }
                EditorGUI.LabelField(nameRect, element.name);
            }
            GUI.EndGroup();
            return(clicked);
        }
        void Delete()
        {
            if (IsActionSelected)
            {
                ControlScheme scheme = schemes[selectedControlSchemeIndex];

                if (selectedActionIndex >= 0 && selectedActionIndex < scheme.Actions.Count)
                {
                    scheme.Actions.RemoveAt(selectedActionIndex);
                }
            }
            else if (IsControlSchemeSelected)
            {
                schemes.RemoveAt(selectedControlSchemeIndex);
            }

            InputManagerWindow.ResetSelections();
            InputManagerWindow.instance.Repaint();
        }
Esempio n. 8
0
        static bool DrawSubElement(Rect position, int i, int j, HieararchyGUIElement subElement)
        {
            bool clicked  = false;
            Rect nameRect = new Rect(HIERARCHY_INDENT_SIZE, 1.0f, position.width - HIERARCHY_INDENT_SIZE, position.height - 1.0f);

            if (Event.current.type == EventType.MouseDown && (Event.current.button == 0 || Event.current.button == 1))
            {
                if (position.Contains(Event.current.mousePosition))
                {
                    InputManagerWindow.ResetSelections();

                    InputManagerWindow.SetSelection(0, i);
                    InputManagerWindow.SetSelection(1, j);

                    clicked = true;
                    Event.current.Use();
                    GUI.FocusControl(null);
                    InputManagerWindow.instance.Repaint();

                    if (Event.current.button == 1)
                    {
                        subElement.createContextMenu(new Rect(Event.current.mousePosition, Vector2.zero));
                    }
                }
            }

            GUI.BeginGroup(position);
            if (InputManagerWindow.GetSelection(1) >= 0 && InputManagerWindow.GetSelection(0) == i && InputManagerWindow.GetSelection(1) == j)
            {
                GUI.DrawTexture(new Rect(0, 0, position.width, position.height), m_highlightTexture, ScaleMode.StretchToFill);
                EditorGUI.LabelField(nameRect, subElement.name, m_whiteLabel);
            }
            else
            {
                EditorGUI.LabelField(nameRect, subElement.name);
            }
            GUI.EndGroup();

            return(clicked);
        }
        void ReorderInputAction(MoveDirection dir)
        {
            if (IsActionSelected)
            {
                var scheme      = schemes[selectedControlSchemeIndex];
                var schemeIndex = selectedControlSchemeIndex;
                var actionIndex = selectedActionIndex;

                if (dir == MoveDirection.Up && actionIndex > 0)
                {
                    SwapActions(scheme, actionIndex, actionIndex - 1);
                    InputManagerWindow.ResetSelections();
                    selectedControlSchemeIndex = schemeIndex;
                    selectedActionIndex        = actionIndex - 1;
                }
                else if (dir == MoveDirection.Down && actionIndex < scheme.Actions.Count - 1)
                {
                    SwapActions(scheme, actionIndex, actionIndex + 1);
                    InputManagerWindow.ResetSelections();
                    selectedControlSchemeIndex = schemeIndex;
                    selectedActionIndex        = actionIndex + 1;
                }
            }
        }
        void ReorderControlScheme(MoveDirection dir)
        {
            if (IsControlSchemeSelected)
            {
                var index = selectedControlSchemeIndex;

                if (dir == MoveDirection.Up && index > 0)
                {
                    var temp = schemes[index];
                    schemes[index]     = schemes[index - 1];
                    schemes[index - 1] = temp;
                    InputManagerWindow.ResetSelections();
                    selectedControlSchemeIndex = index - 1;
                }
                else if (dir == MoveDirection.Down && index < schemes.Count - 1)
                {
                    var temp = schemes[index];
                    schemes[index]     = schemes[index + 1];
                    schemes[index + 1] = temp;
                    InputManagerWindow.ResetSelections();
                    selectedControlSchemeIndex = index + 1;
                }
            }
        }
 void ReloadProfilesAndRepaint()
 {
     gamepadProfiles = GamepadHandler.LoadAllGamepadProfiles();
     InputManagerWindow.ResetSelections();
     InputManagerWindow.instance.Repaint();
 }
 void DisposeManagerWindow(bool repeat)
 {
     instance = null;
     controlSchemes.Dispose(repeat);
     hierarchyGUI.Dispose();
 }