UI update 02
This commit is contained in:
@@ -18,9 +18,9 @@ public class storeItemPrefab : MonoBehaviour, IPointerClickHandler, IPointerEnte
|
||||
public Text thisItem_priceText;
|
||||
|
||||
[Header("other")]
|
||||
public GameObject rightCorner_statusImage; //这个是用来显示限量或新品等状态的图标
|
||||
public GameObject leftCorner_statusImage; //这个是用来显示售罄等状态的图标
|
||||
public GameObject lock_cannotClickImage; //这个是用来显示无法点击的锁图标的
|
||||
public GameObject rightCorner_statusImage; //这个是用来显示限量或新品等状态的图标
|
||||
public GameObject leftCorner_statusImage; //这个是用来显示售罄等状态的图标
|
||||
public GameObject lock_cannotClickImage; //这个是用来显示无法点击的锁图标的
|
||||
|
||||
[Header("texts")]
|
||||
public Text why_cannot_buy;
|
||||
@@ -30,7 +30,12 @@ public class storeItemPrefab : MonoBehaviour, IPointerClickHandler, IPointerEnte
|
||||
public Text itemTitle;
|
||||
public Text itemDescription;
|
||||
|
||||
[Header("quick buy")]
|
||||
public Button quickBuyButton;
|
||||
public Material quickBuy_cannotBuy_mtr;
|
||||
|
||||
public Action<storeItemPrefab> onItemClicked;
|
||||
public Action<storeItemPrefab> onQuickBuyClicked;
|
||||
|
||||
private const float ShowDelay = 0.5f;
|
||||
private const float HideDelay = 0.25f;
|
||||
@@ -40,10 +45,13 @@ public class storeItemPrefab : MonoBehaviour, IPointerClickHandler, IPointerEnte
|
||||
private Coroutine pendingShowCoroutine;
|
||||
private Coroutine pendingHideCoroutine;
|
||||
private int lastNotifyFrame = -1;
|
||||
private Graphic quickBuyGraphic;
|
||||
private Material quickBuyDefaultMaterial;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
PrepareDescriptionPanel();
|
||||
PrepareQuickBuyButton();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
@@ -114,6 +122,29 @@ public class storeItemPrefab : MonoBehaviour, IPointerClickHandler, IPointerEnte
|
||||
}
|
||||
}
|
||||
|
||||
public void NotifyQuickBuyClicked()
|
||||
{
|
||||
if (onQuickBuyClicked != null)
|
||||
{
|
||||
onQuickBuyClicked(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void RefreshQuickBuyState(bool canQuickBuy)
|
||||
{
|
||||
if (quickBuyButton != null)
|
||||
{
|
||||
quickBuyButton.interactable = canQuickBuy;
|
||||
}
|
||||
|
||||
if (quickBuyGraphic == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
quickBuyGraphic.material = canQuickBuy ? quickBuyDefaultMaterial : quickBuy_cannotBuy_mtr;
|
||||
}
|
||||
|
||||
public void SetDescriptionContent(string title, string description)
|
||||
{
|
||||
if (itemTitle != null)
|
||||
@@ -123,7 +154,7 @@ public class storeItemPrefab : MonoBehaviour, IPointerClickHandler, IPointerEnte
|
||||
|
||||
if (itemDescription != null)
|
||||
{
|
||||
itemDescription.text = string.IsNullOrWhiteSpace(description) ? "暂无描述信息" : description;
|
||||
itemDescription.text = string.IsNullOrWhiteSpace(description) ? "暂无描述信息" : description;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,6 +178,28 @@ public class storeItemPrefab : MonoBehaviour, IPointerClickHandler, IPointerEnte
|
||||
descriptionObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void PrepareQuickBuyButton()
|
||||
{
|
||||
if (quickBuyButton == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
quickBuyButton.onClick.RemoveListener(NotifyQuickBuyClicked);
|
||||
quickBuyButton.onClick.AddListener(NotifyQuickBuyClicked);
|
||||
|
||||
quickBuyGraphic = quickBuyButton.targetGraphic;
|
||||
if (quickBuyGraphic == null)
|
||||
{
|
||||
quickBuyGraphic = quickBuyButton.GetComponent<Graphic>();
|
||||
}
|
||||
|
||||
if (quickBuyGraphic != null)
|
||||
{
|
||||
quickBuyDefaultMaterial = quickBuyGraphic.material;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator ShowDescriptionWithDelay()
|
||||
{
|
||||
yield return new WaitForSeconds(ShowDelay);
|
||||
|
||||
Reference in New Issue
Block a user