using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using UnityEngine; using UnityEngine.UI; using UnityEngine.EventSystems; using UnityEngine.Events; using DG.Tweening; using System.Timers; namespace Assets.Scripts.UI.Control { [RequireComponent(typeof(Button))] public class PfUIButton : PFUIComponentBase { public enum Type { Normal, Border, Primary, Image } [SerializeField] Type mType; [SerializeField] string Tooltips; private GameObject tooltips; private Image image; private Text text; //private Texture2D cursor; private Outline outline; private Button mButton; protected void Awake() { #if !(UNITY_ANDROID || UNITY_IOS) //pc版依然让tooltip变成下面的 var newtool = transform.Find("Tooltips").gameObject; var newrect = newtool.GetComponent(); newrect.anchorMin = new Vector2(0.5f, 1); newrect.anchorMax = new Vector2(0.5f, 1); newrect.pivot = new Vector2(0.5f, 1); newrect.anchoredPosition = new Vector2(0, -50); //newrect.transform.localPosition = newrect.GetTruePosition(new Vector2(0, -50)); // -16 -66 0 -50 #endif outline = this.GetComponent(); if (mType == Type.Border && outline == null) { outline = this.gameObject.AddComponent(); outline.effectDistance = new Vector2(2, 2); } //设置光标 //cursor = Resources.Load("Images/PointerButtonHover"); image = gameObject.GetComponent(); text = this.transform.Find("Text").GetComponent(); if(mType == Type.Image) { text.gameObject.SetActive(false); } else { 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; } tooltips = this.transform.Find("Tooltips").gameObject; if (!string.IsNullOrWhiteSpace(Tooltips)) { // //tooltips.GetComponent().localPosition. tooltips.transform.Find("Text").GetComponent().text = App.GetLocalString(Tooltips); var pftext = tooltips.transform.Find("Text").GetComponent(); Debug.Log(pftext); if (pftext) { tooltips.transform.Find("Text").GetComponent().key = Tooltips; } } tooltips.SetActive(false); mButton = this.GetComponent