private void DrawMapEditorUtils() { var data = world.GridDataReference.CellData; var zoom = SceneView.currentDrawingSceneView.camera.orthographicSize; var typeValues = Enum.GetValues(typeof(GridContentType)) as GridContentType[]; Handles.BeginGUI(); for (int i = 0; i < data.Length; i++) { var worldPos = world.CellToWorld(data[i].CellPosition) - (world.GridDataReference.CellSize / 2) + new Vector2(0, world.GridDataReference.CellSize.y); var screenPos = HandleUtility.WorldToGUIPoint(worldPos); var cellRect = new Rect( screenPos, new Vector2(world.GridDataReference.CellSize.x, world.GridDataReference.CellSize.y) * 322f / zoom ); var tex = GetTextureForContentType(data[i].ContentType); if (GUI.Button(cellRect, tex)) { var curTypeIndex = Array.FindIndex(typeValues, type => world.GridDataReference.CellData[i].ContentType == type); world.GridDataReference.CellData[i].ContentType = typeValues[++curTypeIndex % typeValues.Length]; } } Handles.EndGUI(); }