86 lines
2.4 KiB
C#
86 lines
2.4 KiB
C#
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
|
|
{
|
|
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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 给对象设置圆角
|
|
/// </summary>
|
|
/// <param name="panel"></param>
|
|
/// <param name="radius"></param>
|
|
protected void SetRounded(Transform panel, float radius)
|
|
{
|
|
var rounded = Resources.Load<Material>("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<Image>();
|
|
if (img != null)
|
|
{
|
|
img.material = material;
|
|
return;
|
|
}
|
|
var rawImg = panel.GetComponent<RawImage>();
|
|
if (rawImg != null)
|
|
{
|
|
rawImg.material = material;
|
|
return;
|
|
}
|
|
}
|
|
protected void BindHeadImage()
|
|
{
|
|
if (!transform.Find("HeadImage")) return;
|
|
var headImage = this.transform.Find("HeadImage").GetComponent<RawImage>();
|
|
var material = Instantiate(Resources.Load<Material>("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();
|
|
});
|
|
}
|
|
}
|
|
//}
|