Unable to resize through code after docking a panel
Description of the bug
So I tried to dock a RectTransform using code and it doesn't seem to resize properly, it's stuck at MinSize still even though I don't want it to start at MinSize,
Despite debugging making sure the Vector2 I used is correct, the panel is still resized towards it's minimum size
Reproduction steps
Here's the code I'm using
using DynamicPanels;
using UnityEngine;
namespace Rhitomata {
public class GameUI : MonoBehaviour {
public DynamicPanelsCanvas dynamicCanvas;
[Header("Timeline")]
public RectTransform timelinePanel;
public Vector2 timelineMinSize = new(200f, 100f);
[HideInInspector] public Panel dynamicTimelinePanel;
[HideInInspector] public PanelTab dynamicTimelinePanelTab;
private void Awake() {
// Timeline
var previousTimelineSize = timelinePanel.rect.size;
dynamicTimelinePanel = PanelUtils.CreatePanelFor(timelinePanel, dynamicCanvas);
dynamicTimelinePanel.DockToRoot(Direction.Bottom);
dynamicTimelinePanelTab = PanelUtils.GetAssociatedTab(timelinePanel);
dynamicTimelinePanelTab.MinSize = timelineMinSize;
dynamicTimelinePanelTab.Icon = null;
dynamicTimelinePanelTab.Label = "Timeline";
dynamicTimelinePanel.ResizeTo(previousTimelineSize);
}
}
}
Platform specs
Please provide the following info if this is a Unity 3D repository.
- Unity version: 6000.0.51f1
- Platform: Unity Editor
- Device: Lenovo Thinkpad L15 Gen 1
- How did you download the plugin: GitHub
Additional info None
DynamicPanelsCanvas builds its layout in Start: https://github.com/yasirkula/UnityDynamicPanels/blob/f69af3a9cdecb93ee00e28cb8a10e54fd3a9d957/Plugins/DynamicPanels/Scripts/DynamicPanelsCanvas.cs#L280-L333
It might be possible that this process overrides your code that is inside Awake (which is invoked before Start). Could you try executing your code in Start?