Answer the question
In order to leave comments, you need to log in
How to disable the grid display in the editor?
Hello
Please tell me how can I enable / disable the standard unit grid in the gizmo: ShowGrid through the script?
I rummaged through the entire Internet and did not find such an implementation, is it even possible?
Answer the question
In order to leave comments, you need to log in
The class you need is called AnnotationUtility, it's internal, so you can't get close to it without reflection.
using System.Reflection;
using UnityEditor;
public class Test
{
[MenuItem("Test/ShowGrid")]
private static void ShowGrid()
{
var type = typeof (Editor).Assembly.GetType("UnityEditor.AnnotationUtility");
var property = type.GetProperty("showGrid", BindingFlags.Static | BindingFlags.NonPublic);
bool showGrid = (bool) property.GetValue(null, null);
property.SetValue(null, !showGrid, null);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question