| 1234567891011121314151617181920212223242526272829303132333435363738 | using UnityEngine;using UnityEngine.UI;public class UISpiritLoader : MonoBehaviour{    public bool Ratio;    public MyImage Image;    private Vector2 ImageSizeData;    private Vector2 LoaderSizeData;    [ContextMenu("SetLoaderSpirit")]    public void SetLoaderSpirit()    {        //Image.SetNativeSize();        Image.GetComponent<RectTransform>().localScale = new Vector3(1, 1, 1);        LoaderSizeData = GetComponent<RectTransform>().sizeDelta;        ImageSizeData = Image.GetComponent<RectTransform>().sizeDelta;        if (Ratio)        {            if (LoaderSizeData.x > LoaderSizeData.y)            {                float ys = LoaderSizeData.y / ImageSizeData.y;                Image.GetComponent<RectTransform>().localScale = new Vector3(ys, ys, ys);            }            else            {                float xs = LoaderSizeData.x / ImageSizeData.x;                Image.GetComponent<RectTransform>().localScale = new Vector3(xs, xs, xs);            }            Image.GetComponent<RectTransform>().localPosition = Vector3.zero;        }    }}
 |