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); }
public override void OnInspectorGUI() { SerializedProperty mapName = serializedObject.FindProperty("mapName"); SerializedProperty buttonMap = serializedObject.FindProperty("buttonMap"); SerializedProperty value = serializedObject.FindProperty("value"); SerializedProperty activeArea = serializedObject.FindProperty("activeArea"); SerializedProperty Activated = serializedObject.FindProperty("Activated"); SerializedProperty DeActivated = serializedObject.FindProperty("Deactivated"); SerializedProperty StateChanged = serializedObject.FindProperty("StateChanged"); mapName.stringValue = EditorGUILayout.TextField(mapName.stringValue); EditorGUILayout.BeginHorizontal(); InputMappingNew.InputType typeSwitch = (InputMappingNew.InputType)EditorGUILayout.EnumPopup(InputMappingNew.InputType.Button); buttonMap.enumValueIndex = (int)(FloatMap.FloatInput)EditorGUILayout.EnumPopup((ButtonMap.Buttons)buttonMap.enumValueIndex); EditorGUILayout.EndHorizontal(); bool splitActivation = Screen.width > 480; Utils.EditorUtils.SplitPropertyView(Activated, DeActivated, splitActivation); EditorGUILayout.PropertyField(StateChanged); serializedObject.ApplyModifiedProperties(); if (typeSwitch != InputMappingNew.InputType.Button) { InputMappingNew.SwitchType((ButtonMap)target, typeSwitch); } }
public override void OnInspectorGUI() { SerializedProperty mapName = serializedObject.FindProperty("mapName"); SerializedProperty vector2Map = serializedObject.FindProperty("vector2Map"); SerializedProperty activeRange = serializedObject.FindProperty("activeRange"); SerializedProperty MovedX = serializedObject.FindProperty("MovedX"); SerializedProperty MovedY = serializedObject.FindProperty("MovedY"); SerializedProperty StateChanged = serializedObject.FindProperty("StateChanged"); SerializedProperty Touched = serializedObject.FindProperty("Touched"); SerializedProperty UnTouched = serializedObject.FindProperty("UnTouched"); SerializedProperty Clicked = serializedObject.FindProperty("Clicked"); SerializedProperty UnClicked = serializedObject.FindProperty("UnClicked"); mapName.stringValue = EditorGUILayout.TextField(mapName.stringValue); EditorGUILayout.BeginHorizontal(); InputMappingNew.InputType typeSwitch = (InputMappingNew.InputType)EditorGUILayout.EnumPopup(InputMappingNew.InputType.Joystick_Trackpad); vector2Map.enumValueIndex = (int)(FloatMap.FloatInput)EditorGUILayout.EnumPopup((Vector2Map.Axis2D)vector2Map.enumValueIndex); EditorGUILayout.EndHorizontal(); bool splitActivation = Screen.width > 480; Utils.EditorUtils.SplitPropertyView(MovedX, MovedY, splitActivation); EditorGUILayout.PropertyField(StateChanged); EditorGUILayout.Space(); Utils.EditorUtils.SplitPropertyView(Touched, UnTouched, splitActivation); Utils.EditorUtils.SplitPropertyView(Clicked, UnClicked, splitActivation); serializedObject.ApplyModifiedProperties(); if (typeSwitch != InputMappingNew.InputType.Joystick_Trackpad) { InputMappingNew.SwitchType((Vector2Map)target, typeSwitch); } }
public override void OnInspectorGUI() { SerializedProperty mapName = serializedObject.FindProperty("mapName"); SerializedProperty floatMap = serializedObject.FindProperty("floatMap"); SerializedProperty activeRange = serializedObject.FindProperty("activeRange"); SerializedProperty Activated = serializedObject.FindProperty("Activated"); SerializedProperty Deactivated = serializedObject.FindProperty("Deactivated"); SerializedProperty StateChanged = serializedObject.FindProperty("StateChanged"); mapName.stringValue = EditorGUILayout.TextField(mapName.stringValue); EditorGUILayout.BeginHorizontal(); InputMappingNew.InputType typeSwitch = (InputMappingNew.InputType)EditorGUILayout.EnumPopup(InputMappingNew.InputType.Trigger_Grab); floatMap.enumValueIndex = (int)(FloatMap.FloatInput)EditorGUILayout.EnumPopup((FloatMap.FloatInput)floatMap.enumValueIndex); EditorGUILayout.EndHorizontal(); var tempRange = new FloatRange(activeRange.vector2Value); Utils.EditorUtils.ShowRangeArea(ref tempRange); activeRange.vector2Value = tempRange.ToVector2(); bool splitActivation = Screen.width > 480; Utils.EditorUtils.SplitPropertyView(Activated, Deactivated, splitActivation); EditorGUILayout.PropertyField(StateChanged); serializedObject.ApplyModifiedProperties(); if (typeSwitch != InputMappingNew.InputType.Trigger_Grab) { InputMappingNew.SwitchType((FloatMap)target, typeSwitch); } }