public void SellStick() { if (activeStick != null) { Debug.Log("You have sold " + activeStick + " at index " + activeStickIndex); //Get ID of Plus or Minus stick for this character. int tradeStickID = GetIDOfResultantTradedStick(StickGameManager.Instance.GetTrader(), activeStick); InventoryStick newStick = Instantiate(stickPrefab); //Destroy old stick Debug.Log("Destroying " + inventory[activeStickIndex]); Destroy(inventory[activeStickIndex].gameObject); newStick.Init(activeStickIndex, this, allSticks[tradeStickID]); newStick.transform.SetParent(inventoryUIRoot); newStick.transform.SetSiblingIndex(activeStickIndex); hasTraded = true; tradeButton.interactable = false; //invUI.SetActive(false); //the idea is to get the ui to disappear and for the dialogue to start } else { Debug.LogError("The active stick was null"); } }
void CreateInventory() { int index = 0; inventory = new InventoryStick[startingSticks.Length]; foreach (int id in startingSticks) { InventoryStick newStick = Instantiate(stickPrefab); inventory[index] = newStick; newStick.Init(index, this, allSticks[id]); newStick.transform.SetParent(inventoryUIRoot); newStick.transform.SetSiblingIndex(index); index++; } }