1234567891011121314151617181920212223242526272829 |
- using Sirenix.OdinInspector;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class ScaleContronl : MonoBehaviour
- {
- [LabelText("比例基准")]
- public float scaleBase;
- [LabelText("检测对象")]
- public RectTransform m_RectTransform;
- [LabelText("需要调整比例对象")]
- public RectTransform[] m_ChangeTransforms;
- /// <summary>
- /// 更新比例
- /// </summary>
- public void UpdateScale()
- {
- float scale = m_RectTransform.sizeDelta.y / scaleBase;
- foreach (RectTransform t in m_ChangeTransforms)
- {
- t.localScale = new Vector3(t.localScale.x,scale,t.localScale.z);
- }
- }
- }
|