Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Plugins/DynamicPanels/Scripts/Helpers/PanelTab.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.EventSystems;
using UnityEngine.UI;

Expand All @@ -24,6 +25,7 @@ public void Initialize( Panel panel, RectTransform content )
{
tab.m_panel = panel;
tab.Content = content;
tab.MinSize = content.rect.size;
}

public void ChangeCloseButtonVisibility( bool isVisible )
Expand Down Expand Up @@ -100,6 +102,8 @@ public Vector2 MinSize
{
if( m_minSize != value )
{
if (value.x < 0) value = new Vector2(-value.x, value.y);
if (value.y < 0) value = new Vector2(value.x, -value.y);
m_minSize = value;
m_panel.Internal.RecalculateMinSize();
}
Expand Down Expand Up @@ -133,7 +137,7 @@ public string Label

private void Awake()
{
m_minSize = new Vector2( 100f, 100f );
m_minSize = new Vector2( -1f, -1f );
Internal = new InternalSettings( this );

iconHolder.preserveAspect = true;
Expand Down
7 changes: 5 additions & 2 deletions Plugins/DynamicPanels/Scripts/Panel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public void OnApplicationQuit()
public Vector2 Position { get { return RectTransform.anchoredPosition; } }
public Vector2 Size { get { return RectTransform.sizeDelta; } }

private Vector2 m_minSize = new Vector2( 200f, 200f );
private Vector2 m_minSize = new Vector2( -1f, -1f );
public Vector2 MinSize
{
get { return m_minSize; }
Expand Down Expand Up @@ -450,6 +450,7 @@ public PanelTab AddTab( RectTransform tabContent, int tabIndex = -1 )
tabIndex = tabs.Count;

int thisTabIndex = GetTabIndex( tabContent );
Vector2? newTabContentSize = null;
if( thisTabIndex == -1 )
{
PanelTab tab = PanelUtils.GetAssociatedTab( tabContent );
Expand All @@ -458,6 +459,7 @@ public PanelTab AddTab( RectTransform tabContent, int tabIndex = -1 )
tab = (PanelTab) Instantiate( Resources.Load<PanelTab>( "DynamicPanelTab" ), tabsParent, false );
tabs.Insert( tabIndex, tab );

newTabContentSize = tabContent.rect.size;
tabContent.anchorMin = Vector2.zero;
tabContent.anchorMax = Vector2.one;
tabContent.sizeDelta = Vector2.zero;
Expand All @@ -475,8 +477,9 @@ public PanelTab AddTab( RectTransform tabContent, int tabIndex = -1 )
}

tab.Internal.Initialize( this, tabContent );
if (newTabContentSize != null) tab.MinSize = newTabContentSize.Value;
tab.Internal.RectTransform.SetSiblingIndex( tabIndex );

tabContent.SetParent( null, false ); // workaround for a rare internal Unity crash
tabContent.SetParent( contentParent, false );

Expand Down