private void OnEnable() { EditorToolbox.ShowStartupWarning(); _intputConfigurations = serializedObject.FindProperty("inputConfigurations"); _dontDestroyOnLoad = serializedObject.FindProperty("dontDestroyOnLoad"); _defaultConfiguration = serializedObject.FindProperty("defaultConfiguration"); }
private void HandleFileMenuOption(object arg) { FileMenuOptions option = (FileMenuOptions)arg; switch (option) { case FileMenuOptions.OverriteInputSettings: EditorToolbox.OverwriteInputSettings(); break; case FileMenuOptions.CreateSnapshot: EditorToolbox.CreateSnapshot(_inputManager); break; case FileMenuOptions.LoadSnapshot: EditorToolbox.LoadSnapshot(_inputManager); break; case FileMenuOptions.Export: ExportInputConfigurations(); break; case FileMenuOptions.Import: ImportInputConfigurations(); break; case FileMenuOptions.ImportJoystickMapping: EditorToolbox.OpenImportJoystickMappingWindow(this); break; case FileMenuOptions.ConfigureForInputAdapter: ConfigureForInputAdapter(); break; } }
private void DisplayMainToolbar() { Rect screenRect = new Rect(0.0f, 0.0f, position.width, _toolbarHeight); Rect fileMenuRect = new Rect(0.0f, 0.0f, _menuWidth, screenRect.height); Rect editMenuRect = new Rect(fileMenuRect.xMax, 0.0f, _menuWidth, screenRect.height); Rect paddingLabelRect = new Rect(editMenuRect.xMax, 0.0f, screenRect.width - _menuWidth * 2, screenRect.height); Rect searchFieldRect = new Rect(screenRect.width - (_menuWidth * 1.5f + 5.0f), 2.0f, _menuWidth * 1.5f, screenRect.height - 2.0f); int lastSearchStringLength = _searchString.Length; GUI.BeginGroup(screenRect); DisplayFileMenu(fileMenuRect); DisplayEditMenu(editMenuRect); EditorGUI.LabelField(paddingLabelRect, "", EditorStyles.toolbarButton); GUILayout.BeginArea(searchFieldRect); _searchString = EditorToolbox.SearchField(_searchString); GUILayout.EndArea(); GUI.EndGroup(); if (lastSearchStringLength != _searchString.Length) { UpdateSearchResults(); } }
private void OnEnable() { EditorToolbox.ShowStartupWarning(); CreateGUIStyles(); IsOpen = true; if (_inputManager == null) { _inputManager = UnityEngine.Object.FindObjectOfType(typeof(InputManager)) as InputManager; } if (_configurationFoldouts == null) { _configurationFoldouts = new List <bool>(); UpdateFoldouts(); } if (_selectionPath == null) { _selectionPath = new List <int>(); } if (_highlightTexture == null) { CreateHighlightTexture(); } if (_searchResults == null) { _searchResults = new List <SearchResult>(); } }
private void OnEnable() { EditorToolbox.ShowStartupWarning(); IsOpen = true; _tryedToFindInputManagerInScene = false; if (_inputManager == null) { _inputManager = UnityEngine.Object.FindObjectOfType(typeof(InputManager)) as InputManager; } if (_selectionPath == null) { _selectionPath = new List <int>(); } if (_searchResults == null) { _searchResults = new List <SearchResult>(); } if (_highlightTexture == null) { CreateHighlightTexture(); } EditorApplication.playmodeStateChanged += HandlePlayModeChanged; }
private void HandleFileMenuOption(object arg) { int option = (int)arg; switch (option) { case 0: EditorToolbox.OverwriteInputSettings(); break; case 1: EditorToolbox.CreateSnapshot(_inputManager); break; case 2: EditorToolbox.LoadSnapshot(_inputManager); break; case 3: MenuCommands.OpenForumPage(); break; case 4: MenuCommands.OpenAboutDialog(); break; } }
private void CreateFileMenu(Rect position) { GenericMenu fileMenu = new GenericMenu(); fileMenu.AddItem(new GUIContent("Overwrite Input Settings"), false, HandleFileMenuOption, 0); fileMenu.AddSeparator(""); if (_inputManager.inputConfigurations.Count > 0) { fileMenu.AddItem(new GUIContent("Create Snapshot"), false, HandleFileMenuOption, 1); } else { fileMenu.AddDisabledItem(new GUIContent("Create Snapshot")); } if (EditorToolbox.CanLoadSnapshot()) { fileMenu.AddItem(new GUIContent("Load Snapshot"), false, HandleFileMenuOption, 2); } else { fileMenu.AddDisabledItem(new GUIContent("Load Snapshot")); } fileMenu.AddSeparator(""); fileMenu.AddItem(new GUIContent("Forum"), false, HandleFileMenuOption, 3); fileMenu.AddItem(new GUIContent("About"), false, HandleFileMenuOption, 4); fileMenu.DropDown(position); }
private void OnEnable() { _joystickOptions = EditorToolbox.GenerateJoystickNames(); _axisOptions = EditorToolbox.GenerateJoystickAxisNames(); EditorToolbox.ShowStartupWarning(); IsOpen = true; _tryedToFindInputManagerInScene = false; if (_inputManager == null) { _inputManager = UnityEngine.Object.FindObjectOfType(typeof(_InputManager)) as _InputManager; } if (_selectionPath == null) { _selectionPath = new List <int>(); } if (_searchResults == null) { _searchResults = new List <SearchResult>(); } if (_highlightTexture == null) { CreateHighlightTexture(); } EditorApplication.playModeStateChanged += HandlePlayModeChanged; _isDisposed = false; }
public override void OnInspectorGUI() { _InputManager inputManager = target as _InputManager; serializedObject.Update(); GUILayout.Space(5.0f); GUILayout.BeginHorizontal(); GUI.enabled = !AdvancedInputEditor.IsOpen; if (GUILayout.Button("Input\nEditor", GUILayout.Height(40.0f))) { AdvancedInputEditor.OpenWindow(inputManager); } GUI.enabled = true; if (GUILayout.Button(_createSnapshotIngo, GUILayout.Height(40.0f))) { EditorToolbox.CreateSnapshot(inputManager); } GUI.enabled = EditorToolbox.CanLoadSnapshot(); if (GUILayout.Button("Restore\nSnapshot", GUILayout.Height(40.0f))) { EditorToolbox.LoadSnapshot(inputManager); } GUI.enabled = true; GUILayout.EndHorizontal(); GUILayout.Space(5.0f); EditorGUILayout.PropertyField(_playerOneDefault); EditorGUILayout.PropertyField(_playerTwoDefault); EditorGUILayout.PropertyField(_playerThreeDefault); EditorGUILayout.PropertyField(_playerFourDefault); EditorGUILayout.PropertyField(_dontDestroyOnLoad); EditorGUILayout.PropertyField(_ignoreTimescale); EditorGUILayout.PropertyField(_intputConfigurations); if (_intputConfigurations.isExpanded) { EditorGUI.indentLevel++; int arraySize = EditorGUILayout.DelayedIntField("Size", _intputConfigurations.arraySize); if (arraySize != _intputConfigurations.arraySize) { _intputConfigurations.arraySize = arraySize; } for (int i = 0; i < _intputConfigurations.arraySize; i++) { DisplayInputConfigurations(_intputConfigurations.GetArrayElementAtIndex(i)); } EditorGUI.indentLevel--; } GUILayout.Space(5.0f); serializedObject.ApplyModifiedProperties(); }
private void OnEnable() { EditorToolbox.ShowStartupWarning(); _intputConfigurations = serializedObject.FindProperty("inputConfigurations"); _dontDestroyOnLoad = serializedObject.FindProperty("dontDestroyOnLoad"); _ignoreTimescale = serializedObject.FindProperty("ignoreTimescale"); _playerOneDefault = serializedObject.FindProperty("playerOneDefault"); _playerTwoDefault = serializedObject.FindProperty("playerTwoDefault"); _playerThreeDefault = serializedObject.FindProperty("playerThreeDefault"); _playerFourDefault = serializedObject.FindProperty("playerFourDefault"); }
private void DisplayAxisConfiguration(SerializedProperty axisConfig) { EditorGUILayout.PropertyField(axisConfig); if (!axisConfig.isExpanded) { return; } SerializedProperty name = axisConfig.FindPropertyRelative("name"); SerializedProperty description = axisConfig.FindPropertyRelative("description"); SerializedProperty positive = axisConfig.FindPropertyRelative("positive"); SerializedProperty altPositive = axisConfig.FindPropertyRelative("altPositive"); SerializedProperty negative = axisConfig.FindPropertyRelative("negative"); SerializedProperty altNegative = axisConfig.FindPropertyRelative("altNegative"); SerializedProperty deadZone = axisConfig.FindPropertyRelative("deadZone"); SerializedProperty gravity = axisConfig.FindPropertyRelative("gravity"); SerializedProperty sensitivity = axisConfig.FindPropertyRelative("sensitivity"); SerializedProperty snap = axisConfig.FindPropertyRelative("snap"); SerializedProperty invert = axisConfig.FindPropertyRelative("invert"); SerializedProperty type = axisConfig.FindPropertyRelative("type"); SerializedProperty axis = axisConfig.FindPropertyRelative("axis"); SerializedProperty joystick = axisConfig.FindPropertyRelative("joystick"); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(name); EditorGUILayout.PropertyField(description); // Positive Key EditorToolbox.KeyCodeField(ref _keyString, ref _editingPositiveKey, "Positive", "inspector_positive_key", PropertyToKeyCode(positive)); ProcessKeyString(ref _editingPositiveKey, positive); // Negative Key EditorToolbox.KeyCodeField(ref _keyString, ref _editingNegativeKey, "Negative", "inspector_negative_key", PropertyToKeyCode(negative)); ProcessKeyString(ref _editingNegativeKey, negative); // Alt Positive Key EditorToolbox.KeyCodeField(ref _keyString, ref _editingAltPositiveKey, "Alt Positive", "inspector_alt_positive_key", PropertyToKeyCode(altPositive)); ProcessKeyString(ref _editingAltPositiveKey, altPositive); // Alt Negative Key EditorToolbox.KeyCodeField(ref _keyString, ref _editingAltNegativeKey, "Alt Negative", "inspector_alt_negative_key", PropertyToKeyCode(altNegative)); ProcessKeyString(ref _editingAltNegativeKey, altNegative); EditorGUILayout.PropertyField(gravity, _gravityInfo); EditorGUILayout.PropertyField(deadZone, _deadZoneInfo); EditorGUILayout.PropertyField(sensitivity, _sensitivityInfo); EditorGUILayout.PropertyField(snap, _snapInfo); EditorGUILayout.PropertyField(invert); EditorGUILayout.PropertyField(type); axis.intValue = EditorGUILayout.Popup("Axis", axis.intValue, _axisOptions); joystick.intValue = EditorGUILayout.Popup("Joystick", joystick.intValue, _joystickOptions); EditorGUI.indentLevel--; }
private void DisplayAxisConfigurationFields(InputConfiguration inputConfigx, AxisConfiguration axisConfig, Rect screenRect) { GUIContent gravityInfo = new GUIContent("Gravity", "The speed(in units/sec) at which a digital axis falls towards neutral."); GUIContent sensitivityInfo = new GUIContent("Sensitivity", "The speed(in units/sec) at which an axis moves towards the target value."); GUIContent snapInfo = new GUIContent("Snap", "If input switches direction, do we snap to neutral and continue from there? For digital axes only."); GUIContent deadZoneInfo = new GUIContent("Dead Zone", "Size of analog dead zone. Values within this range map to neutral."); GUILayout.BeginArea(screenRect); _mainPanelScrollPos = GUILayout.BeginScrollView(_mainPanelScrollPos); axisConfig.name = EditorGUILayout.TextField("Name", axisConfig.name); axisConfig.description = EditorGUILayout.TextField("Description", axisConfig.description); // Positive Key EditorToolbox.KeyCodeField(ref _keyString, ref _editingPositiveKey, "Positive", "editor_positive_key", axisConfig.positive); ProcessKeyString(ref axisConfig.positive, ref _editingPositiveKey); // Negative Key EditorToolbox.KeyCodeField(ref _keyString, ref _editingNegativeKey, "Negative", "editor_negative_key", axisConfig.negative); ProcessKeyString(ref axisConfig.negative, ref _editingNegativeKey); // Alt Positive Key EditorToolbox.KeyCodeField(ref _keyString, ref _editingAltPositiveKey, "Alt Positive", "editor_alt_positive_key", axisConfig.altPositive); ProcessKeyString(ref axisConfig.altPositive, ref _editingAltPositiveKey); // Alt Negative key EditorToolbox.KeyCodeField(ref _keyString, ref _editingAltNegativeKey, "Alt Negative", "editor_alt_negative_key", axisConfig.altNegative); ProcessKeyString(ref axisConfig.altNegative, ref _editingAltNegativeKey); axisConfig.gravity = EditorGUILayout.FloatField(gravityInfo, axisConfig.gravity); axisConfig.deadZone = EditorGUILayout.FloatField(deadZoneInfo, axisConfig.deadZone); axisConfig.sensitivity = EditorGUILayout.FloatField(sensitivityInfo, axisConfig.sensitivity); axisConfig.snap = EditorGUILayout.Toggle(snapInfo, axisConfig.snap); axisConfig.invert = EditorGUILayout.Toggle("Invert", axisConfig.invert); axisConfig.type = (InputType)EditorGUILayout.EnumPopup("Type", axisConfig.type); axisConfig.axis = EditorGUILayout.Popup("Axis", axisConfig.axis, _axisOptions); axisConfig.joystick = EditorGUILayout.Popup("Joystick", axisConfig.joystick, _joystickOptions); if (EditorApplication.isPlaying) { EditorGUILayout.Space(); GUI.enabled = false; EditorGUILayout.FloatField("Raw Axis", axisConfig.GetAxisRaw()); EditorGUILayout.FloatField("Axis", axisConfig.GetAxis()); EditorGUILayout.Toggle("Button", axisConfig.GetButton()); GUI.enabled = true; } GUILayout.EndScrollView(); GUILayout.EndArea(); }
private void OnEnable() { _joystickOptions = EditorToolbox.GenerateJoystickNames(); _axisOptions = EditorToolbox.GenerateJoystickAxisNames(); EditorToolbox.ShowStartupWarning(); _intputConfigurations = serializedObject.FindProperty("_inputConfigurations"); _dontDestroyOnLoad = serializedObject.FindProperty("_dontDestroyOnLoad"); _ignoreTimescale = serializedObject.FindProperty("_ignoreTimescale"); _playerOneDefault = serializedObject.FindProperty("_playerOneDefault"); _playerTwoDefault = serializedObject.FindProperty("_playerTwoDefault"); _playerThreeDefault = serializedObject.FindProperty("_playerThreeDefault"); _playerFourDefault = serializedObject.FindProperty("_playerFourDefault"); }
private void CreateFileMenu(Rect position) { GenericMenu fileMenu = new GenericMenu(); fileMenu.AddItem(new GUIContent("Overwrite Input Settings"), false, HandleFileMenuOption, FileMenuOptions.OverriteInputSettings); fileMenu.AddItem(new GUIContent("Default Input Configuration"), false, HandleFileMenuOption, FileMenuOptions.CreateDefaultInputConfig); if (EditorToolbox.HasInputAdapterAddon()) { fileMenu.AddItem(new GUIContent("Configure For Input Adapter"), false, HandleFileMenuOption, FileMenuOptions.ConfigureForInputAdapter); } fileMenu.AddSeparator(""); if (_inputManager.inputConfigurations.Count > 0) { fileMenu.AddItem(new GUIContent("Create Snapshot"), false, HandleFileMenuOption, FileMenuOptions.CreateSnapshot); } else { fileMenu.AddDisabledItem(new GUIContent("Create Snapshot")); } if (EditorToolbox.CanLoadSnapshot()) { fileMenu.AddItem(new GUIContent("Load Snapshot"), false, HandleFileMenuOption, FileMenuOptions.LoadSnapshot); } else { fileMenu.AddDisabledItem(new GUIContent("Load Snapshot")); } fileMenu.AddSeparator(""); if (_inputManager.inputConfigurations.Count > 0) { fileMenu.AddItem(new GUIContent("Export"), false, HandleFileMenuOption, FileMenuOptions.Export); } else { fileMenu.AddDisabledItem(new GUIContent("Export")); } fileMenu.AddItem(new GUIContent("Import"), false, HandleFileMenuOption, FileMenuOptions.Import); if (EditorToolbox.HasJoystickMappingAddon()) { fileMenu.AddItem(new GUIContent("Import Joystick Mapping"), false, HandleFileMenuOption, FileMenuOptions.ImportJoystickMapping); } fileMenu.DropDown(position); }
private void DisplayToolbar(Rect screenRect) { Rect searchFieldRect = new Rect(screenRect.width - (_searchFieldWidth + 5.0f), 2.0f, _searchFieldWidth, screenRect.height - 2.0f); int lastSearchStringLength = _searchString.Length; EditorGUI.LabelField(screenRect, "", EditorStyles.toolbarButton); GUILayout.BeginArea(searchFieldRect); _searchString = EditorToolbox.SearchField(_searchString); GUILayout.EndArea(); if (lastSearchStringLength != _searchString.Length) { UpdateSearchResults(); } }
private void HandleFileMenuOption(object arg) { FileMenuOptions option = (FileMenuOptions)arg; switch (option) { case FileMenuOptions.OverriteInputSettings: EditorToolbox.OverwriteInputSettings(); break; case FileMenuOptions.CreateSnapshot: EditorToolbox.CreateSnapshot(_inputManager); break; case FileMenuOptions.LoadSnapshot: EditorToolbox.LoadSnapshot(_inputManager); break; case FileMenuOptions.Export: ExportInputConfigurations(); break; case FileMenuOptions.Import: ImportInputConfigurations(); break; case FileMenuOptions.ImportJoystickMapping: EditorToolbox.OpenImportJoystickMappingWindow(this); break; case FileMenuOptions.ConfigureForInputAdapter: LoadInputConfigurationsFromResource(ResourcePaths.INPUT_ADAPTER_DEFAULT_CONFIG); break; case FileMenuOptions.CreateDefaultInputConfig: LoadInputConfigurationsFromResource(ResourcePaths.INPUT_MANAGER_DEFAULT_CONFIG); break; } }