123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- using System;
- using UnityEngine;
- using UnityEngine.EventSystems;
- using UnityEngine.UI;
- namespace SRF.UI
- {
- [RequireComponent(typeof(RectTransform))]
- [AddComponentMenu("SRF/UI/Copy Layout Element")]
- [ExecuteInEditMode]
- public class CopyLayoutElement : UIBehaviour, ILayoutElement
- {
- public float preferredWidth
- {
- get
- {
- if (!this.CopyPreferredWidth || this.CopySource == null || !this.IsActive())
- {
- return -1f;
- }
- return LayoutUtility.GetPreferredWidth(this.CopySource) + this.PaddingPreferredWidth;
- }
- }
- public float preferredHeight
- {
- get
- {
- if (!this.CopyPreferredHeight || this.CopySource == null || !this.IsActive())
- {
- return -1f;
- }
- return LayoutUtility.GetPreferredHeight(this.CopySource) + this.PaddingPreferredHeight;
- }
- }
- public float minWidth
- {
- get
- {
- if (!this.CopyMinWidth || this.CopySource == null || !this.IsActive())
- {
- return -1f;
- }
- return LayoutUtility.GetMinWidth(this.CopySource) + this.PaddingMinWidth;
- }
- }
- public float minHeight
- {
- get
- {
- if (!this.CopyMinHeight || this.CopySource == null || !this.IsActive())
- {
- return -1f;
- }
- return LayoutUtility.GetMinHeight(this.CopySource) + this.PaddingMinHeight;
- }
- }
- public int layoutPriority
- {
- get
- {
- return 2;
- }
- }
- public float flexibleHeight
- {
- get
- {
- return -1f;
- }
- }
- public float flexibleWidth
- {
- get
- {
- return -1f;
- }
- }
- public void CalculateLayoutInputHorizontal()
- {
- }
- public void CalculateLayoutInputVertical()
- {
- }
- public bool CopyMinHeight;
- public bool CopyMinWidth;
- public bool CopyPreferredHeight;
- public bool CopyPreferredWidth;
- public RectTransform CopySource;
- public float PaddingMinHeight;
- public float PaddingMinWidth;
- public float PaddingPreferredHeight;
- public float PaddingPreferredWidth;
- }
- }
|