NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/Common/UINode.cs

73 lines
1.3 KiB
C#
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using UnityEngine;
using UnityEngine.UI;
public class UINode: MonoBehaviour
{
public static UINode LoadNode()
{
return null;
}
protected void ClearBind(Button button)
{
button.onClick.RemoveAllListeners();
}
protected void BindButton(Button button, Action func)
{
button.onClick.AddListener(() =>
{
func?.Invoke();
});
}
protected void BindButton<T>(Button button, Action<T> func, T param)
{
button.onClick.AddListener(() =>
{
func?.Invoke(param);
});
}
protected T _GetComponent<T>(string path) where T: Behaviour
{
var compGo = transform.Find(path).gameObject;
if (compGo)
{
return compGo.GetComponent<T>();
}
DebugUtil.LogError($"{name}未找到组件{typeof(T).Name} {path}");
return null;
}
public virtual void OnAwake()
{
}
public virtual void OnStart()
{
}
public virtual void OnUpdate()
{
}
public virtual void SetData(object data)
{
}
public virtual void OnShow()
{
}
public virtual void OnHide()
{
}
}