Implement action bar.
This commit is contained in:
29
Assets/Cryville/Crtr/Browsing/UI/ActionButton.cs
Normal file
29
Assets/Cryville/Crtr/Browsing/UI/ActionButton.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Cryville.Crtr.Browsing.Actions;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Cryville.Crtr.Browsing.UI {
|
||||
internal class ActionButton : MonoBehaviour, IPointerClickHandler {
|
||||
[SerializeField]
|
||||
TextMeshProUGUI m_text;
|
||||
|
||||
ResourceBrowser _browser;
|
||||
IResourceAction _action;
|
||||
|
||||
public void Load(ResourceBrowser browser, IResourceAction action) {
|
||||
gameObject.SetActive(true);
|
||||
_browser = browser;
|
||||
_action = action;
|
||||
m_text.text = action.Name;
|
||||
}
|
||||
public void Clear() {
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData) {
|
||||
if (_action == null) return;
|
||||
_browser.InvokeAction(_action);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user