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 Assets.Scripts; //namespace Assets.Scripts.UI.Prefab.Panel //{ public class PFUIPanel : UIBehaviour { [HideInInspector]public NewMainNav newNav = null; public void OpenURL(string url) { Application.OpenURL(url); } public virtual void Show() { base.gameObject.SetActive(true); } public virtual void Close() { //DestroyImmediate(this.gameObject); this.gameObject.SetActive(false); } public void AddChild(PFUIPanel child) { if(child == null) { return; } child.transform.SetParent(this.transform); } /// /// 给对象设置圆角 /// /// /// protected void SetRounded(Transform panel, float radius) { var rounded = Resources.Load("UI/Material/RoundedCornersTextureMaterial"); var material = Instantiate(rounded); var rect = ((RectTransform)panel).rect; material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, radius, 0)); var img = panel.GetComponent(); if (img != null) { img.material = material; return; } var rawImg = panel.GetComponent(); if (rawImg != null) { rawImg.material = material; return; } } protected void BindHeadImage() { if (!transform.Find("HeadImage")) return; var headImage = this.transform.Find("HeadImage").GetComponent(); var material = Instantiate(Resources.Load("UI/Material/RoundedCornersTextureMaterial")); var rect = ((RectTransform)headImage.transform).rect; material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height, 0)); headImage.material = material; //if (App.FromLogin) //{ Utils.DisplayHead(headImage, App.CurrentUser.WxHeadImg); //} UIManager.AddEvent(headImage.gameObject, EventTriggerType.PointerClick, (e) => { UIManager.ShowUserInfoPanel(); }); } } //}