using UnityEngine;
|
using UnityEngine.UI;
|
using UnityEngine.Events;
|
|
public class SkillBaseCell : MonoBehaviour
|
{
|
|
Image m_SkillIcon;
|
Image skillIcon
|
{
|
get
|
{
|
if (m_SkillIcon == null)
|
{
|
m_SkillIcon = this.transform.GetComponent<Image>("Container_SkillCell/Img_Icon");
|
}
|
return m_SkillIcon;
|
}
|
}
|
|
Button m_SkillBtn;
|
Button skillBtn
|
{
|
get
|
{
|
if (m_SkillBtn == null)
|
{
|
m_SkillBtn = this.transform.GetComponent<Button>("Container_SkillCell");
|
}
|
return m_SkillBtn;
|
}
|
}
|
|
|
Text m_SkillType;
|
Text skillType
|
{
|
get
|
{
|
if (m_SkillType == null)
|
{
|
m_SkillType = this.transform.GetComponent<Text>("Container_SkillCell/type");
|
}
|
return m_SkillType;
|
}
|
}
|
|
void Awake()
|
{
|
LoadPrefab();
|
}
|
|
private void Init(int skillID, UnityAction onclick, bool showType = false)
|
{
|
var config = SkillConfig.Get(skillID);
|
skillIcon.SetSprite(config.IconName);
|
skillBtn.AddListener(onclick);
|
|
if (showType)
|
{
|
skillType.text = Language.Get(config.FuncType == 23 ? "HeroSkillType_1" : "HeroSkillType_2");
|
}
|
else
|
{
|
skillType.text = string.Empty;
|
}
|
}
|
|
GameObject cellContainer;
|
protected void LoadPrefab()
|
{
|
if (cellContainer != null)
|
return;
|
|
var tmp = transform.Find("Container_SkillCell");
|
if (tmp != null)
|
{
|
cellContainer = tmp.gameObject;
|
return;
|
}
|
if (cellContainer == null)
|
{
|
cellContainer = UIUtility.CreateWidget("SkillBaseCell", "Container_SkillCell");
|
|
if (cellContainer != null)
|
{
|
cellContainer.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one);
|
cellContainer.transform.SetAsFirstSibling();
|
}
|
}
|
}
|
}
|