This repository has been archived on 2025-08-02. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Cryville.EEW.Unity/Assets/Cryville.Common/Unity/UI/DockAspectRatioLayoutGroup.cs
2025-02-14 16:06:00 +08:00

25 lines
753 B
C#

using UnityEngine;
namespace Cryville.Common.Unity.UI {
/// <summary>
/// A <see cref="DockLayoutGroup" /> that sets the aspect ratio of the docking element.
/// </summary>
[AddComponentMenu("Layout/Dock Aspect Ratio Layout Group")]
public sealed class DockAspectRatioLayoutGroup : DockLayoutGroup {
[SerializeField]
[Tooltip("The aspect ratio of the docking element.")]
private float m_dockAspectRatio = 1;
/// <summary>
/// The aspect ratio of the docking element.
/// </summary>
public float DockAspectRatio {
get { return m_dockAspectRatio; }
set { base.SetProperty(ref m_dockAspectRatio, value); }
}
protected override float GetDockElementSize(Vector2 groupSize) {
return groupSize.y * m_dockAspectRatio;
}
}
}