public InputMappingNew AddMap(InputMappingNew.InputType mappingType, string newName = "") { var parent = manager.transform.Find("InputMappings"); if (!parent) { new GameObject("InputMappings").transform.parent = manager.transform; return(AddMap(mappingType, newName)); } InputMappingNew tempMapping = null; switch (mappingType) { case InputMappingNew.InputType.Button: tempMapping = (InputMappingNew)Undo.AddComponent(parent.gameObject, typeof(ButtonMap)); break; case InputMappingNew.InputType.Trigger_Grab: tempMapping = (InputMappingNew)Undo.AddComponent(parent.gameObject, typeof(FloatMap)); break; case InputMappingNew.InputType.Joystick_Trackpad: tempMapping = (InputMappingNew)Undo.AddComponent(parent.gameObject, typeof(Vector2Map)); break; } if (!newName.Equals("")) { tempMapping.mapName = newName; } manager.RefreshInputMappings(); return(tempMapping); }
private void OnEnable() { manager = (InputManagerNew)target; manager.RefreshInputMappings(); SerializedProperty interactor = serializedObject.FindProperty("interactor"); SerializedProperty grabMap = serializedObject.FindProperty("grabMap"); if (interactor.objectReferenceValue == null) { InteractorRaw _interactor = null; _interactor = manager.GetComponent <InteractorRaw>(); if (_interactor == null) { _interactor = manager.GetComponentInParent <InteractorRaw>(); } interactor.objectReferenceValue = _interactor; } if (grabMap.objectReferenceValue == null) { foreach (var map in manager.inputMappings) { Debug.Log(map.mapName.ToLower().Contains("grab")); if (map.mapName.ToLower().Contains("grab")) { grabMap.objectReferenceValue = map; } } } serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { //base.OnInspectorGUI(); //manager = (InputManager)target; SerializedProperty handedness = serializedObject.FindProperty("handedness"); SerializedProperty grabMap = serializedObject.FindProperty("grabMap"); SerializedProperty inputMappingsProperty = serializedObject.FindProperty("inputMappings"); if (grabMap.objectReferenceValue == null) { foreach (var map in manager.inputMappings) { Debug.Log(map.mapName.ToLower().Contains("grab map set")); if (map.mapName.ToLower().Contains("grab")) { grabMap.objectReferenceValue = map; } } } manager = (InputManagerNew)target; manager.RefreshInputMappings(); GUILayout.Label($"{(InputManagerNew.hands)handedness.intValue} InputManager Maps: " + $"{inputMappingsProperty.arraySize}, Interactor: {manager.interactor != null} " + $"(grabMap({manager.grabMap != null}))"); //GUILayout.Label($"Grab Map: {(manager.grabMap ? manager.grabMap.mapName : "NULL")}"); //System.Collections.IEnumerator inputMappings ShowInputMapping(inputMappingsProperty); if (!manager.grabMap) { if (GUILayout.Button("Add Grab")) { AddGrab(); } } EditorGUILayout.BeginHorizontal(); GUILayout.Space(30); if (GUILayout.Button("Add Button Map")) { AddMap(InputMappingNew.InputType.Button, "new Button"); } if (GUILayout.Button("Add Float Map")) { AddMap(InputMappingNew.InputType.Trigger_Grab, "new Float"); } if (GUILayout.Button("Add Vector2 Map")) { AddMap(InputMappingNew.InputType.Joystick_Trackpad, "new Vector2"); } GUILayout.Space(30); EditorGUILayout.EndHorizontal(); //if (Selection.activeGameObject == manager.gameObject && manager.rig) // if (GUILayout.Button($"GOTO: {manager.rig.name}")) // EditorUtils.FocusObject(manager.rig.gameObject); GUILayout.Space(10); }