using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using UnityEngine; using UnityEngine.UI; namespace Assets.Scripts.UI.Control { [RequireComponent(typeof(Button))] public class PFUIRoundButton : PFUIComponentBase { private Image image; private Text text; protected void Awake() { image = gameObject.GetComponent(); text = this.transform.Find("Text").GetComponent(); Material material = null; if (material == null) { material = Instantiate(Resources.Load("UI/Material/RoundedCornersTextureMaterial")); } var rect = ((RectTransform)transform).rect; material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height * 0.5f, 0)); image.material = material; } } }