Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix initial panels being created too large #21

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Henri-J-Norden
Copy link

Issue: Panel.m_minSize is initialized to (200, 200), but when an initial panel with smaller tabContent is added, the panel is created larger than the tabContent, because in PanelUtils.CreatePanel:

  • the call to result.AddTab calls Internal.RecalculateMinSize, which updates m_minSize to the correct value
  • but this ^ is done after setting result.FloatingSize = contentRect.size;, which already clamped the panel size to the initial (200, 200) value

Fix: avoid initializing Panel.m_minSize to a value > 0 to support creating panels smaller than (200, 200)

@yasirkula
Copy link
Owner

On a project that I'm working on, I've encountered an issue where initial sizes of anchored panels wouldn't be respected in some cases. I've resolved it by changing the following lines:

if( initialSizes.TryGetValue( panel, out initialSize ) )
panel.ResizeTo( initialSize, Direction.Right, Direction.Top );

As follows:

if( initialSizes.TryGetValue( panel, out initialSize ) )
{
	if( initialSize.x <= Mathf.Epsilon )
		initialSize.x = panel.Size.x;
	if( initialSize.y <= Mathf.Epsilon )
		initialSize.y = panel.Size.y;

	panel.ResizeTo( initialSize, Direction.Right, Direction.Top );
}

I'm wondering if this fix applies to your scenario, as well. Did you encounter this issue on free panels? If not, could you provide simple repro steps for me to follow?

@Henri-J-Norden
Copy link
Author

Yes, I had the issue with free panels. But I also encountered a related problem when using PanelUtils.CreatePanelFor, because the tab MinSize is set after changing the content rectTransform anchors and parent (so the content size is already changed from the initial when MinSize is recorded). My latest commit should fix both issues now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants