How to select the item inside of my inventory slot? (Followed a tutorial into a rut)
Hi, as I have started coding, I have been following a "Coding With Unity" inventory tutorial on youtube. I'm trying to make a "destroy item" menu, but he does not cover it, so I have been trying to implement it, using his system and have found myself lost.
Based on the tutorials I have: https://pastebin.com/Rb1khU5U This inventory script that controls the backend management of the player's inventory object https://pastebin.com/MhQfiBKP This DISPLAY inventory script that takes the backend and displays it as UI elements
And this busted attempt to try and figure out what is inside of a selected, displayed inventory slot (the colors work to show that its selected-- but i need the item that is contained in the slot and don't know how to get to it/reference it:
public class SelectDeselectScript : MonoBehaviour, ISelectHandler, IDeselectHandler
{
public Toggle toggle;
private ToggleGroup toggleGroup;
public static bool togSelected = false;
public InventoryObject inventory;
private void Start()
{
toggle = GetComponent<Toggle>();
toggle.onValueChanged.AddListener(OnToggleValueChanged);
}
private void OnToggleValueChanged(bool isOn)
{
ColorBlock cb = toggle.colors;
if (isOn)
{
cb.normalColor = Color.gray;
cb.selectedColor = Color.gray;
//Select or define what is inside of the selected slot?
togSelected = true;
//Then after the CONTENTS of the slot are selected above, I can access this toggle from another script i think?
}
else
{
cb.normalColor = Color.white;
cb.selectedColor = Color.white;
}
toggle.colors = cb;}
If anything is unclear please let me know, I've been fiddling with this system for almost a week and I cannot figure it out :^(