I am trying to find a ScriptableObject using a variable it has. For instance:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AClassName : MonoBehaviour {
public void findItemByID(int ID) {
// A way to find the ScriptableObject by it's value
}
void Start() {
findItemByID(7);
addItemToInventory(the Item we got from findItemByID);
}
}
I’ve been trying to find out a way of doing this for 2 days. Any help would be appreciated!
EDIT: Here’s my ScriptableObject class:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu]
public class Items : ScriptableObject {
public Sprite itemSprite;
public string itemName;
public int itemId;
}