D
D
Dmitry2016-11-11 04:54:11
Unity
Dmitry, 2016-11-11 04:54:11

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

2 answer(s)
D
Daniil Basmanov, 2016-11-11
@Dimusikus

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);
    }
}

G
GreatRash, 2016-11-11
@GreatRash

lmgtfy

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question