using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
//官职和称号:根据用户选择,佩戴称号的情况下优先显示称号
|
//组件默认参考大小为官职的底图大小
|
public class OfficialTitleCell : MonoBehaviour
|
{
|
private void Awake()
|
{
|
//如果有需要按钮点击逻辑,在外层创建,此处不处理点击逻辑
|
LoadPrefab();
|
|
}
|
|
|
Image m_OfficialRankObj;
|
private Image officialRankObj
|
{
|
get
|
{
|
if (m_OfficialRankObj == null)
|
{
|
m_OfficialRankObj = this.GetComponent<Image>("OfficialTitleCell/offcialRank");
|
}
|
return m_OfficialRankObj;
|
}
|
}
|
|
|
Text m_OfficialRankText;
|
private Text officialRankText
|
{
|
get
|
{
|
if (m_OfficialRankText == null)
|
{
|
m_OfficialRankText = this.GetComponent<Text>("OfficialTitleCell/offcialRank/text");
|
}
|
return m_OfficialRankText;
|
}
|
}
|
|
ImageEx m_TitleImage;
|
private ImageEx titleImage
|
{
|
get
|
{
|
if (m_TitleImage == null)
|
{
|
m_TitleImage = this.GetComponent<ImageEx>("OfficialTitleCell/Img_Title");
|
}
|
return m_TitleImage;
|
}
|
}
|
|
|
|
UIFrame m_UIFrame;
|
private UIFrame titleUIFrame
|
{
|
get
|
{
|
if (m_UIFrame == null)
|
{
|
m_UIFrame = this.GetComponent<UIFrame>("OfficialTitleCell/Img_Title");
|
}
|
return m_UIFrame;
|
}
|
}
|
|
UIEffectPlayer m_UIEffectPlayer;
|
private UIEffectPlayer effectPlayer
|
{
|
get
|
{
|
if (m_UIEffectPlayer == null)
|
{
|
m_UIEffectPlayer = this.GetComponent<UIEffectPlayer>("OfficialTitleCell/Img_Title/UIEffectPlayer");
|
}
|
return m_UIEffectPlayer;
|
}
|
}
|
|
|
GameObject prefab;
|
|
|
protected void LoadPrefab()
|
{
|
if (prefab != null)
|
return;
|
var tmp = transform.Find("OfficialTitleCell");
|
|
if (tmp != null)
|
{
|
prefab = tmp.gameObject;
|
return;
|
}
|
prefab = UIUtility.CreateWidget("OfficialTitleCell", "OfficialTitleCell");
|
|
prefab.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one);
|
prefab.transform.SetAsFirstSibling();
|
|
}
|
|
public void InitUI(int offcialRank, int titleID)
|
{
|
LoadPrefab(); //存在被卸载的可能,重新加载
|
if (titleID == 0)
|
{
|
officialRankObj.SetActive(true);
|
var config = RealmConfig.Get(offcialRank);
|
officialRankObj.SetSprite("OfficialRank" + config.Quality);
|
|
titleUIFrame.SetActive(false);
|
officialRankText.text = config.Name;
|
officialRankText.color = OfficialRankManager.Instance.GetOfficialRankColor(config.Quality);
|
}
|
else
|
{
|
officialRankObj.SetActive(false);
|
titleUIFrame.SetActive(true);
|
titleUIFrame.enabled = false;
|
|
int resourceType = PhantasmPavilionManager.Instance.GetResourceType(PhantasmPavilionType.Title, titleID);
|
string resourceValue = PhantasmPavilionManager.Instance.GetResourceValue(PhantasmPavilionType.Title, titleID);
|
PhantasmPavilionManager.Instance.Show(titleImage, effectPlayer, titleUIFrame, resourceType, resourceValue);
|
}
|
}
|
|
}
|