idk what I need to do to be inside the bounds of my array. i think my array is stuck not counting at all or counting to much between my 2 interfaces but idk if thats even the problem with it i just know its an array problem in my CreateSlots don't know if this helps but I'm following a unity tutorial called Unity3D equipping items scriptable object inventory system 'the code':
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class StaticInterface : UserInterface
{
public GameObject[] Slots;
public override void CreateSlots()
{
itemsDisplayed = new Dictionary<GameObject, InventorySlot>();
for (int i = 0; i < inventory.Container.Items.Length; i++)
{
var obj = Slots[i]; //this line is the one unity pointed out
AddEvent(obj, EventTriggerType.PointerEnter, delegate { OnEnter(obj); });
AddEvent(obj, EventTriggerType.PointerExit, delegate { OnExit(obj); });
AddEvent(obj, EventTriggerType.BeginDrag, delegate { OnDragStart(obj); });
AddEvent(obj, EventTriggerType.EndDrag, delegate { OnDragEnd(obj); });
AddEvent(obj, EventTriggerType.Drag, delegate { OnDrag(obj); });
itemsDisplayed.Add(obj, inventory.Container.Items[i]);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using UnityEngine.Events;
public abstract class UserInterface : MonoBehaviour
{
public Player player;
public InventoryObject inventory;
public Dictionary<GameObject, InventorySlot> itemsDisplayed = new Dictionary<GameObject, InventorySlot>();
void Start()
{
CreateSlots();
}
// Update is called once per frame
void Update()
{
UpdateSlots();
}
public abstract void CreateSlots();//this line is the one unity pointed out