Skip to content
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

Add EditorInterface methods to get the 2D current grid snapping options #101114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Jan 4, 2025

The following methods are available:

  • EditorInterface.is_2d_editor_grid_snap_enabled()
  • EditorInterface.is_2d_editor_smart_snap_enabled()
  • EditorInterface.is_2d_editor_snap_relative_enabled()
  • EditorInterface.is_2d_editor_snap_rotation_enabled()
  • EditorInterface.is_2d_editor_snap_scale_enabled()
  • EditorInterface.get_2d_editor_grid_offset()
  • EditorInterface.get_2d_editor_grid_offset()
  • EditorInterface.get_2d_editor_grid_primary_steps()
  • EditorInterface.get_2d_editor_grid_step()
  • EditorInterface.get_2d_editor_snap_rotation_offset()
  • EditorInterface.get_2d_editor_snap_rotation_step()
  • EditorInterface.get_2d_editor_snap_scale_step()

Note that in 3D, the grid size is defined by the editors/3d/grid_size editor setting, but it's separate from snapping which is defined on a per-scene basis like in 2D. I suggest unifying this to make it work more like the 2D editor before adding methods that expose it to editor plugins.


Testing project: test-2d-editor-grid-plugin.zip

@Calinou Calinou added this to the 4.x milestone Jan 4, 2025
@Calinou Calinou requested a review from a team as a code owner January 4, 2025 01:42
@Calinou Calinou force-pushed the editor-plugin-add-2d-grid-methods branch from a1eb5a2 to f6a39aa Compare January 4, 2025 02:02
@erayzesen
Copy link

An important feature set I was expecting, and thank you for your efforts. It would also be great if a feature were added to check whether the user has enabled the 'snap to grid' option in the editor. We usually need this when writing editor plugins for canvas editing, in order to accommodate the user's enabled/disabled 'snap to grid' setting.

@Calinou Calinou force-pushed the editor-plugin-add-2d-grid-methods branch 2 times, most recently from ec6f4ca to 6ee51ba Compare January 4, 2025 22:22
@Calinou
Copy link
Member Author

Calinou commented Jan 4, 2025

An important feature set I was expecting, and thank you for your efforts. It would also be great if a feature were added to check whether the user has enabled the 'snap to grid' option in the editor. We usually need this when writing editor plugins for canvas editing, in order to accommodate the user's enabled/disabled 'snap to grid' setting.

I've added more methods to query the snapping state (check OP).

The following methods are available:

- `EditorInterface.is_2d_editor_grid_snap_enabled()`
- `EditorInterface.is_2d_editor_smart_snap_enabled()`
- `EditorInterface.is_2d_editor_snap_relative_enabled()`
- `EditorInterface.is_2d_editor_snap_rotation_enabled()`
- `EditorInterface.is_2d_editor_snap_scale_enabled()`
- `EditorInterface.get_2d_editor_grid_offset()`
- `EditorInterface.get_2d_editor_grid_primary_steps()`
- `EditorInterface.get_2d_editor_grid_step()`
- `EditorInterface.get_2d_editor_snap_rotation_offset()`
- `EditorInterface.get_2d_editor_snap_rotation_step()`
- `EditorInterface.get_2d_editor_snap_scale_step()`
@Calinou Calinou force-pushed the editor-plugin-add-2d-grid-methods branch from 6ee51ba to e187599 Compare January 4, 2025 22:27
@erayzesen
Copy link

An important feature set I was expecting, and thank you for your efforts. It would also be great if a feature were added to check whether the user has enabled the 'snap to grid' option in the editor. We usually need this when writing editor plugins for canvas editing, in order to accommodate the user's enabled/disabled 'snap to grid' setting.

I've added more methods to query the snapping state (check OP).

Perfect! Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement a way for EditorPlugins to get 2D Editor Grid Snap
2 participants