Untitled
unknown
plain_text
9 months ago
1.4 kB
5
Indexable
public void ShowItemSearchList(HashSet<InventoryData> matchedItems)
{
count = 0;
if (componentPrefab == null || content == null)
{
Debug.LogError("component prefab or content not found");
}
foreach (Transform child in content.transform)
{
Destroy(child.gameObject);
}
Instantiate(componentPrefab, content);
if (matchedItems != null)
{
foreach(InventoryData match in matchedItems)
{
Debug.Log(match.itemID);
count++;
// instantiate prefab in content
GameObject newItem = Instantiate(componentPrefab, content);
// get rect component
RectTransform itemRect = newItem.GetComponent<RectTransform>();
// put in correct spot
itemRect.offsetMax = new Vector2(itemRect.offsetMax.x, itemRect.offsetMax.y - 35 * count);
itemRect.offsetMin = new Vector2(itemRect.offsetMin.x, itemRect.offsetMin.y - 410 - 35 * count);
//show item details
TextMeshProUGUI itemText = newItem.GetComponentInChildren<TextMeshProUGUI>();
itemText.text = match.itemName + ", " + match.itemCost + ", " + match.itemPrice + ", " + match.onHand;
}
}
else
{
Debug.LogError("No rect transform found.");
}
}Editor is loading...
Leave a Comment