I've a procedurally generated hex tilemap, which is larger than the bounds of the screen (when not zoomed out). What I want to do is create a border around the tilemap.
The tilemap is a child of a Canvas object, because I want to be able to write text to the map. What I've done is place a UI panel as a parent of the hex grid, then added a nine-slice image as a background to the panel. Once the tilemap has been generated, I resize the UI panel using the local bounds of the tilemap. Have tried resizing the panel - borderImage in the code below - various ways (including ContentSizeFitters and HorizontalLayouts on the UI panel) with no success. The image just shows up as a small rectangle in the bottom left-hand corner of the screen.
Bounds bounds = map.localBounds;
RectTransform uiTransform = borderImage.GetComponentInParent<RectTransform>();
//uiTransform.localScale = new Vector3(bounds.max.x, bounds.max.y, 0);
uiTransform.sizeDelta = new Vector2(bounds.max.x, bounds.max.y);
Placing the border image on the canvas gives me a border around the screen, but what I want is to have the border around the edges of the tilemap.
Thanks in advance for suggestions about how to solve this problem.