Ok so I'm trying to use anchors to position some items essentially my structure is this:
Background of the prompt.
-- A texture that is anchored to the top of the background at 0, left of the background at 0, right of the background at 0 and has no bottom anchor, with an aspect of 2.
--Some text, anchored to the left of the background at 0, right of the background at 0 and the top anchor is set to the bottom of the texture (aka should be right below it.)
-- Some more text anchored to the bottom of the previous text, with left and right anchored to the background.
-- Finally I anchor the bottom of the background to the bottom of the text (so it encompases the full text / images).
(Basically I want everything to stick to the background width, be arranged below the previous item regardless of size, and for the background to encompass the lot). At this point I should note that the text is being updated at runtime, but before the item is enabled (although in the same frame).
Now, after trying OnEnable with the anchors that hasn't worked; I presumed because the anchoring happened in the wrong order.
I've now tried to include anchor updating in my script:
public UISprite background_sprite;
public UITexture header_image;
public UILabel time_label;
public UILabel event_description;
background_sprite.UpdateAnchors();
header_image.aspectRatio = 1.0f / orca_event.cover_image_ratio;
time_label.text = orca_event.event_time.ToString();
event_description.text = orca_event.event_description;
header_image.UpdateAnchors();
time_label.UpdateAnchors();
event_description.UpdateAnchors();
background_sprite.UpdateAnchors();
Most of this all works as expected; apart from the background which is still over-sized / has a height higher than that of the content (loads of space a the bottom). It'd be great to know what I'm doing wrong as for the life of me I don't know what I'm doing wrong.