Skip to content

Fix InputMap load removing spatial_editor actions in editor #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions addons/block_code/ui/picker/categories/category_factory.gd
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,16 @@ static func get_built_in_blocks(_class_name: String) -> Array[Block]:
static func _get_input_blocks() -> Array[Block]:
var block_list: Array[Block]

var editor_input_actions: Dictionary = {}
var editor_input_action_deadzones: Dictionary = {}
if Engine.is_editor_hint():
var actions := InputMap.get_actions()
for action in actions:
if action.begins_with("spatial_editor"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Cafezinhu are there other actions worth re-adding other than the ones beginning with "spatial_editor"?

var events := InputMap.action_get_events(action)
editor_input_actions[action] = events
editor_input_action_deadzones[action] = InputMap.action_get_deadzone(action)

InputMap.load_from_project_settings()

var block: Block = BLOCKS["parameter_block"].instantiate()
Expand All @@ -701,4 +711,10 @@ static func _get_input_blocks() -> Array[Block]:
block.category = "Input"
block_list.append(block)

if Engine.is_editor_hint():
for action in editor_input_actions.keys():
InputMap.add_action(action, editor_input_action_deadzones[action])
for event in editor_input_actions[action]:
InputMap.action_add_event(action, event)

return block_list