public static void CreateInstance(RectTransform parent, float maxExpand) { Image img = null; if (instance == null) { img = UI_Pool.Instance.GetImage(parent, (int)parent.sizeDelta.x, (int)parent.sizeDelta.y, nameof(UI_Selection)); var selection = img.gameObject.AddComponent <UI_Selection>(); selection.maxExpand = maxExpand; selection.selectionImage = img; instance = selection; } else { img = instance.SelectionImage; img.rectTransform.SetParent(parent); img.rectTransform.sizeDelta = parent.sizeDelta; img.name = nameof(UI_Selection); instance.maxExpand = maxExpand; instance.defaultSizeDelta = parent.sizeDelta; instance.selectionImage = img; } img.rectTransform.localPosition = Vector3.zero; img.sprite = GlobalAssetsReference.InventoryItemOnPointerOver_Sprite; img.type = Image.Type.Sliced; img.raycastTarget = false; }
public static void DestroyInstance() { if (instance == null) { return; } UI_Pool.Instance.RemoveImage(instance.SelectionImage); Destroy(instance); instance = null; }
private void OnPointerClick_Yes(BaseEventData eventData) { if (UI_Shop.Instance.TradeType == TradeType.Buy) { TradeMenu.Mid.ItemProduct.Purchase(); } else { TradeMenu.Mid.ItemProduct.Sell(); } UI_Selection.DestroyInstance(); UI_Shop.Instance.CloseTradeMenu(); }
private void OnPointerEnter(BaseEventData eventData) { OnMouseEnter.Invoke(); UI_Selection.CreateInstance(RectTransform, 24); }
private void OnPointerExit(BaseEventData eventData) { OnMouseExit.Invoke(); UI_Selection.DestroyInstance(); }
private void OnMouseExit() { UI_Selection.DestroyInstance(); }
private void OnMouseEnter() { UI_Selection.CreateInstance(RectTransform, 32); }
private void OnPointerExit_Yes(BaseEventData eventData) { UI_Selection.DestroyInstance(); }
private void OnPointerEnter_Yes(BaseEventData eventData) { UI_Selection.CreateInstance(yes, 24.0f); }
private void OnPointerClick_No(BaseEventData eventData) { UI_Selection.DestroyInstance(); UI_Shop.Instance.CloseTradeMenu(); }