private void Start() { toolTip = GameObject.FindObjectOfType <ToolTip>(); canvas = GameObject.Find("Canvas").GetComponent <Canvas>(); PickedItem = GameObject.Find("PickedItem").GetComponent <ItemUI>(); PickedItem.HideItemUI(); }
/// <summary> /// 减少鼠标上物体的数量并更新鼠标是否有物品 /// </summary> public void ReducePickedItem(int amount = 1) { PickedItem.ReduceAmount(amount); if (PickedItem.Amount <= 0) { isPickedItem = false; PickedItem.HideItemUI(); } }
private void Update() { if (isPickedItem == true) { Vector2 position; RectTransformUtility.ScreenPointToLocalPointInRectangle(canvas.transform as RectTransform, Input.mousePosition, null, out position); PickedItem.SetItemUIPosition(position); } if (isShowToolTip == true) { Vector2 position; RectTransformUtility.ScreenPointToLocalPointInRectangle(canvas.transform as RectTransform, Input.mousePosition, null, out position); toolTip.SetToolTipPosition(position + vector2); } if (isPickedItem == true && Input.GetMouseButtonDown(0) && UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject(-1) == false) { isPickedItem = false; PickedItem.HideItemUI(); } }
/// <summary> /// 鼠标上所有的物品都放入物品槽内 /// </summary> public void ReduceAllPickedItem() { PickedItem.ReduceAmount(PickedItem.Amount); isPickedItem = false; PickedItem.HideItemUI(); }