123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using System;
- using UnityEngine;
- using UnityEngine.UI;
- namespace SRF.UI
- {
- [RequireComponent(typeof(RectTransform))]
- [ExecuteInEditMode]
- [AddComponentMenu("SRF/UI/Copy Size Into Layout Element")]
- public class CopySizeIntoLayoutElement : LayoutElement
- {
- public override float preferredWidth
- {
- get
- {
- if (!this.SetPreferredSize || this.CopySource == null || !this.IsActive())
- {
- return -1f;
- }
- return this.CopySource.rect.width + this.PaddingWidth;
- }
- }
- public override float preferredHeight
- {
- get
- {
- if (!this.SetPreferredSize || this.CopySource == null || !this.IsActive())
- {
- return -1f;
- }
- return this.CopySource.rect.height + this.PaddingHeight;
- }
- }
- public override float minWidth
- {
- get
- {
- if (!this.SetMinimumSize || this.CopySource == null || !this.IsActive())
- {
- return -1f;
- }
- return this.CopySource.rect.width + this.PaddingWidth;
- }
- }
- public override float minHeight
- {
- get
- {
- if (!this.SetMinimumSize || this.CopySource == null || !this.IsActive())
- {
- return -1f;
- }
- return this.CopySource.rect.height + this.PaddingHeight;
- }
- }
- public override int layoutPriority
- {
- get
- {
- return 2;
- }
- }
- public RectTransform CopySource;
- public float PaddingHeight;
- public float PaddingWidth;
- public bool SetPreferredSize;
- public bool SetMinimumSize;
- }
- }
|