Hi,
Is there a way to change the grid size in the editor by using script? I mean the “Grid Visuals” in Grid and Snap window.
the game designer in my team want some utilities to help him speed up level designing, he want to change these settings by some preset value (with a button click) and manual input.
I can change the snap settings with EditorSnapSettings but I cannot find any API to change the grid size.
I’m using Unity 2019.4.9f1
Thank you for reading,
Tom.
2 Likes
system
April 22, 2021, 8:01pm
3
1 Like
Solution: Use Reflection to get the Grid Size property
Assembly assembly = Assembly.Load("UnityEditor.dll");
Type gridSettings = assembly.GetType("UnityEditor.GridSettings");
PropertyInfo gridSize = gridSettings.GetProperty("size");
gridSize.SetValue("size", new Vector3(1,2,3));
4 Likes
Tymianek:
Solution: Use Reflection to get the Grid Size property
Assembly assembly = Assembly.Load("UnityEditor.dll");
Type gridSettings = assembly.GetType("UnityEditor.GridSettings");
PropertyInfo gridSize = gridSettings.GetProperty("size");
gridSize.SetValue("size", new Vector3(1,2,3));
It works like a charm! Thanks.
1 Like
For anyone who’s looking for a conventional method, there’s public API:
EditorSnapSettings.gridSize