Bug Description
After using SteamInventory.GetAllItemsAsync() the item definition of the items are null.
Restarting Steam resolves the issue, however only for one run of the game (in the Unity Editor). On the first run (in the Unity Editor) the item.name is returned fine however after stopping playing and starting again the item.def once again returns null.
To Reproduce
Setup a Unity project with SteamManager.cs on a GameObject
Be logged in to Steam with Steam open
Have access to a Steam App with an item store that has items
Have some of the items from the item store in your Steam inventory
Run.
Calling Code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Steamworks;
using System;
using UnityEngine.UIElements;
using Steamworks.Ugc;
public class SteamManager : MonoBehaviour
{
public List<InventoryItem> steamItemsInInventory = new List<InventoryItem>();
public static SteamManager singleton;
void Start()
{
bool isSingleton = SingletonSetup();
if(isSingleton == false) { return; }
// Initialise Steamworks
try
{
SteamClient.Init(252490 /*app id of rust as an example*/ );
Debug.Log("Initialised Steamworks");
}
catch (System.Exception e)
{
Debug.LogError("Failed to initialise steamworks " + e.Message);
return;
}
GetItems();
}
async void GetItems()
{
steamItemsInInventory.Clear(); // Clear list ready for re-population
var itemStoreDefinitions = await SteamInventory.GetDefinitionsWithPricesAsync(); // Get Item Store Definitions
foreach (var def in itemStoreDefinitions)
{
Debug.Log($"Item for sale : {def.Name}, {def.Description} @ {def.LocalPriceFormatted}, with ID {def.Id}"); // Debug dump the item store definitions
}
var itemsInInventory = await SteamInventory.GetAllItemsAsync(); // Get users inventory data
using (itemsInInventory)
{
var items = itemsInInventory?.GetItems(true); // Get items list from steam users inventory data with properties
foreach (InventoryItem item in items)
{
Debug.Log($"Item in inventory : {item.DefId} "); //OK
Debug.Log($"Details : {item.Def.Name} "); //item.Def is null!
steamItemsInInventory.Add(item); // Add item to list
}
}
}
void Update()
{
Steamworks.SteamClient.RunCallbacks(); // Run SteamWorks callbacks
}
void OnDestroy()
{
Steamworks.SteamClient.Shutdown(); // Shut down SteamWorks after we've finished with it
}
bool SingletonSetup(){
// Singleton Setup
if (GameObject.FindObjectsOfType<SteamManager>().Length > 1)
{
Destroy(gameObject);
return false;
}
singleton = this;
GameObject.DontDestroyOnLoad(gameObject);
return true;
}
}
Expected behavior
item.def to not be null and to contain the items data
Bug Description After using SteamInventory.GetAllItemsAsync() the item definition of the items are null. Restarting Steam resolves the issue, however only for one run of the game (in the Unity Editor). On the first run (in the Unity Editor) the item.name is returned fine however after stopping playing and starting again the item.def once again returns null.
To Reproduce Setup a Unity project with SteamManager.cs on a GameObject Be logged in to Steam with Steam open Have access to a Steam App with an item store that has items Have some of the items from the item store in your Steam inventory Run.
Calling Code
Expected behavior item.def to not be null and to contain the items data
Desktop:
Additional context