public void OnEnable()
{
instances.Add(this);
if (clipboardView == null)
{
clipboardView = CreateInstance <GridPaintPaletteClipboard>();
clipboardView.owner = this;
clipboardView.hideFlags = HideFlags.HideAndDontSave;
clipboardView.unlocked = false;
}
if (m_PaintableSceneViewGrid == null)
{
m_PaintableSceneViewGrid = CreateInstance <PaintableSceneViewGrid>();
m_PaintableSceneViewGrid.hideFlags = HideFlags.HideAndDontSave;
}
GridPaletteBrushes.FlushCache();
EditMode.editModeStarted += OnEditModeStart;
EditMode.editModeEnded += OnEditModeEnd;
GridSelection.gridSelectionChanged += OnGridSelectionChanged;
GridPaintingState.RegisterPainterInterest(this);
GridPaintingState.scenePaintTargetChanged += OnScenePaintTargetChanged;
GridPaintingState.brushChanged += OnBrushChanged;
SceneView.onSceneGUIDelegate += OnSceneViewGUI;
PrefabUtility.prefabInstanceUpdated += PrefabInstanceUpdated;
AssetPreview.SetPreviewTextureCacheSize(256, GetInstanceID());
wantsMouseMove = true;
wantsMouseEnterLeaveWindow = true;
if (m_PreviewResizer == null)
{
m_PreviewResizer = new PreviewResizer();
m_PreviewResizer.Init("TilemapBrushInspector");
}
minSize = new Vector2(240f, 200f);
if (palette == null && TilemapEditorUserSettings.lastUsedPalette != null && GridPalettes.palettes.Contains(TilemapEditorUserSettings.lastUsedPalette))
{
palette = TilemapEditorUserSettings.lastUsedPalette;
}
Tools.onToolChanged += ToolChanged;
ShortcutIntegration.instance.contextManager.RegisterToolContext(m_ShortcutContext);
}