void Use() { Debug.Log("A use!"); print(selectedItem.name); print(selectedItem.GetComponent <Image>().sprite.name); GameObject itemUsed = GameObject.Find(selectedItem.GetComponent <Image>().sprite.name + "Dialogue"); print(itemUsed.name); StartDialogue(itemUsed.GetComponent <NPC>(), "Use"); itemUsed = null; selectedItem.UpdateItem(null); }
private void SwapInfo(UIItem p_dragged) { // swap the images/amounts around Image image = GetComponent <Image>(); Image draggedImage = p_dragged.GetComponent <Image>(); Image otherGhost = p_dragged.m_ghost; TextMeshProUGUI amount = GetComponentInChildren <TextMeshProUGUI>(); TextMeshProUGUI otherAmount = draggedImage.GetComponentInChildren <TextMeshProUGUI>(); TextMeshProUGUI otherGhostAmount = p_dragged.m_ghostAmount; image.sprite = draggedImage.sprite; draggedImage.sprite = m_ghost.sprite; otherGhost.sprite = draggedImage.sprite; m_ghost.sprite = image.sprite; amount.text = otherAmount.text; otherAmount.text = m_ghostAmount.text; m_ghostAmount.text = otherAmount.text; otherGhostAmount.text = otherAmount.text; Color otherColor = draggedImage.color; bool otherAmountEnabled = otherAmount.enabled; draggedImage.color = image.color; image.color = otherColor; otherAmount.enabled = amount.enabled; amount.enabled = otherAmountEnabled; Item current = m_item; m_item = p_dragged.m_item; p_dragged.m_item = current; }
public void LoadEmptyItem(UIItem p_uiItem, Item p_item) { Image image = p_uiItem.GetComponent <Image>(); p_uiItem.m_item = p_item; image.color = new Color(1, 1, 1, 0); p_uiItem.GetComponentInChildren <TextMeshProUGUI>().enabled = false; }
public void LoadOutline(UIItem p_uiItem, Item p_item) { Image image = p_uiItem.GetComponent <Image>(); TextMeshProUGUI amount = p_uiItem.GetComponentInChildren <TextMeshProUGUI>(); image.sprite = p_item.m_outlineSprite; image.color = new Color(1, 1, 1, 1); amount.text = ""; }
private void CopyInfo(UIItem p_dragged) { Image image = GetComponent <Image>(); Image draggedImage = p_dragged.GetComponent <Image>(); TextMeshProUGUI amount = GetComponentInChildren <TextMeshProUGUI>(); TextMeshProUGUI otherAmount = draggedImage.GetComponentInChildren <TextMeshProUGUI>(); image.sprite = draggedImage.sprite; m_ghost.sprite = image.sprite; amount.text = otherAmount.text; m_ghostAmount.text = otherAmount.text; image.color = draggedImage.color; amount.enabled = otherAmount.enabled; }
public override void OnInspectorGUI() { UIItem item = target as UIItem; RectTransform rect = item.GetComponent <RectTransform>(); RectTransform root = rect.root.GetComponent <RectTransform>(); Vector2 size = root.sizeDelta; Vector2 itemSize = rect.sizeDelta; CanvasScaler cs = root.GetComponent <CanvasScaler>(); Bounds bounds = RectTransformUtility.CalculateRelativeRectTransformBounds(root, rect); Vector2 center = new Vector2( bounds.center.x + cs.referenceResolution.x / 2, cs.referenceResolution.y / 2 - bounds.center.y); Vector2 pivot = rect.pivot - new Vector2(0.5f, 0.5f); pivot.y = -pivot.y; center = center + new Vector2(pivot.x * itemSize.x, pivot.y * itemSize.y); center.x = ToFixed(center.x / 2); center.y = ToFixed(center.y / 2); EditorGUILayout.Vector2Field("position", center); EditorGUILayout.Vector2Field("min", new Vector2( ToFixed((cs.referenceResolution.x / 2 + bounds.min.x) / 2), ToFixed((cs.referenceResolution.y / 2 - bounds.min.y - itemSize.y) / 2) )); EditorGUILayout.Vector2Field("max", new Vector2( ToFixed((cs.referenceResolution.x / 2 + bounds.max.x) / 2), ToFixed((cs.referenceResolution.y / 2 - bounds.max.y + itemSize.y) / 2) )); //if (GUILayout.Button("LookAtOrigin")) { //} //GUILayout.EndHorizontal(); }
public override void AcceptModal() { UIItem toDelete = m_info as UIItem; Image image = toDelete.GetComponent <Image>(); if (toDelete == UIItem.HeldItem) { toDelete.HideHeldItem(); } toDelete.m_item.m_inventory.Remove(toDelete.m_item); toDelete.m_item = new Item(toDelete.m_item.m_inventory, toDelete.m_item.m_inventoryIndex); image.color = new Color(255, 255, 255, 0); toDelete.GetComponentInChildren <TextMeshProUGUI>().enabled = false; if (m_eventToFireOnSuccess) { m_eventToFireOnSuccess.Raise(); } CloseModal(); }
public void LoadItem(UIItem p_uiItem, Item p_item) { Image image = p_uiItem.GetComponent <Image>(); TextMeshProUGUI amount = p_uiItem.GetComponentInChildren <TextMeshProUGUI>(); p_uiItem.m_item = p_item; image.sprite = p_item.m_item.m_sprite; p_uiItem.m_ghost.sprite = image.sprite; image.color = new Color(255, 255, 255, 255); p_uiItem.m_ghost.color = new Color(255, 255, 255, 255); if (p_item.m_amount == 1 && p_item.m_item.m_maxStackSize == 1) { amount.text = ""; } else { amount.text = p_item.m_amount.ToString(); } }