- Home /
uGui image element doesn't render
I'm making a menu for my current project. On one of the buttons, I'm using an image child instead of a text child. It renders behind the button for some reason, until I move it about 15 pixels or so.
Hierarchy looks sort of like this (oversimplified):
1. Canvas Set at screen space - camera and attached to the main camera. Also has a graphic raycaster and canvas scaler. Canvas scaler is set to scale with screen size, matching 1280x720 resolution, matching it at 0.5 (the middle).
2. Menu holder The menu holder is the parent to the whole menu's "sections". It has the background image attached to it. It has a vertical layout group so everything inside is placed according to their LayoutElement properties. It has the menu's script attached.
3. Different menu elements Different game objects for each menu "section", e.g. one GameObject for the header, one GameObject for the scroller where the game spawns buttons, etc. Each has a LayoutElement component attached and different properties on it.
3.1, CloseButton A button that closes the whole menu. It has a LayoutElement attached and "Ignore layout" is checked so I can position it in the top right corner without moving it up the hierarchy (so it's the bottom most object, thus being rendered in front of everything. OnClick event is MenuHolder.SetActive(false);
4. CloseImage A child of CloseButton, a simple image that has an icon. It's stretched horizontally and vertically so it matches the CloseButton's size. It's there so I can use the image on CloseButton in other places as well.
So, in short, CloseImage is a child of CloseButton, which is a child of MenuHolder, which is a child of the canvas. CloseButton is ordered last in the hierarchy, so CloseImage being a child, is the last ordered element in the hierarchy.
It just doesn't render. If I move it with the Rect Handles tool, it renders even before exiting the borders of the parent button:
Anyone encounter this problem? For me, it happens in one other menu, which has basically the same structure, and nowhere else, even other similarly ordered menus.
I'm using Unity 5.1.0. At home, I tried with 5.1.2, same results.
Your answer
