Shop Issues (Pause and descriptions)

SOSolacex

Member
Hey.
So I have some issues with the shop.
Whenever I am browsing a shop, my character can still move and look around.
Furthermore, if I press escape while in the shop, the item description closes completely and does not come back even after reentering the shop.
Looking at the inventory canvas, my character is correctly set as the Panel Owner. As seen here: Inventory canvas components
And the shop menu has "Is Menu Panel" correctly set. Shop menu
The player character also has the "Ultimate Inventory System bridge" along with many other components, as seen here. Player Components
 
Furthermore, if I press escape while in the shop, the item description closes completely and does not come back even after reentering the shop.
That might be the clue to why it isn't working.

It looks like I forgot to set the description as a non-selectable panel in the Shop Menu prefab of the schema. I'm not sure how I didn't catch that before.

When a panel is set as non-selectable the DisplayPanelManager won't set it as the currently selected panel.

Try setting that field and let me know if it works after that.
1608798099469.png

If it doesn't solve the issue, try adding a Debug.Log in the Bridge component at line 1458 printing the name of the Menu that was opened. It might give us an idea of why the input isn't being disabled
 
Unfortunately my knowledge of coding... is less than I'd want.
Aside from my own code which at tops includes simple enums, switches etc, I find it hard to know what to really do in someone else's.
What do you recommend me putting in between Debug.Log();? openClosePanelInfo?

Also, could this be the issue?

NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateInventorySystem.Exchange.CurrencyCollection.PotentialQuotientFor (Opsive.UltimateInventorySystem.Exchange.CurrencyCollection other) (at Assets/Opsive/UltimateInventorySystem/Scripts/Exchange/CurrencyCollection.cs:1313)
Opsive.UltimateInventorySystem.Exchange.CurrencyOwner.PotentialQuotientFor (Opsive.UltimateInventorySystem.Exchange.CurrencyCollection amount) (at Assets/Opsive/UltimateInventorySystem/Scripts/Exchange/CurrencyOwner.cs:109)
Opsive.UltimateInventorySystem.UI.Menus.Shop.ShopMenu.OnItemClicked (Opsive.UltimateInventorySystem.UI.Item.ItemViewSlotEventData slotEventData) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Menus/Shop/ShopMenu.cs:331)
Opsive.UltimateInventorySystem.UI.Item.ItemViewSlotsContainerBase+<>c__DisplayClass46_0.<Initialize>b__0 () (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Item/ItemViewSlotsContainerBase.cs:133)
Opsive.UltimateInventorySystem.UI.CompoundElements.ActionButton.Press () (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/CompoundElements/ActionButton.cs:62)
Opsive.UltimateInventorySystem.UI.CompoundElements.ActionButton.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/CompoundElements/ActionButton.cs:105)
Opsive.UltimateInventorySystem.UI.Item.ItemViewSlot.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Item/ItemViewSlot.cs:169)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/Program Files/Unity/Hub/Editor/2020.1.13f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:50)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at C:/Program Files/Unity/Hub/Editor/2020.1.13f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:261)
UnityEngine.EventSystems.EventSystem:Update() (at C:/Program Files/Unity/Hub/Editor/2020.1.13f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:376)

I am honestly fairly sure I am not missing anything.
Shop components
 
Last edited:
From the screen shot you sent, the only weird thing I see is that the shop has a Currency Owner. There's no reason the shop needs a Currency Owner, unless you want to create a custom shop component where the shop can only buy items from the player if it has money.

So when you get an error, it is important to understand that it stops the execution flow of the code. Meaning that everything after the error is never executed. That would explain why the input is not being disabled. Whenever you see an error in the console that's the first thing you should try to fix, as any weird thing that happen afterwards could be an after effect of that error.

My suspicion is that the Shop didn't find your player and therefore there isn't any client inventory OR your player inventory was found but doesn't have a Currency Owner.

Make sure your character has a currency owner on the same gameobject as the player inventory
1609322190720.png

The Shop can find your player inventory in two ways
1) Using the Inventory Identifier: Using the Inventory Identifier is super easy. It is a unique ID for that Inventory and allows you to find the Inventory from anywhere because it is registered to the InventorySystemManager singleton.

2) When the player interacts with the shop: You can check the demo scene to see how it is setup, The "Interactable" gameobject under the Shop prefab has the components required to make that work. This is useful in case you have multiple players each with their inventory which can interact with the shop.

1609322300253.png

Choose the option that suits you best
 
I added a currency owner on the shop, because I'd get "The client inventory is either null or it does not have a currencyOwner." if I didn't.
I also did all that you said before, but it didn't work. I believe I changed the client inventory identifier index back to 0 after it didn't work.
 
An Inventory Identifier of 0 means it won't look for the inventory using the identifier.
You can drag and drop the character inventory as the client inventory if you prefer (but of course you'll need both the shop and the character in the same scene for that to work)

If it is still not working I would recommend you create a new scene with just the shop, shop menu and the character.

My suspicion is that you are using the shop inventory as the client inventory, which is wrong. The client inventory should be the player.
This would explain why you had that warning about the client inventory missing a currency owner and why adding it to the shop removed that warning.

Compare your shop setup with the demo shop set up and see if you can find any differences.

You can also check the inspector in play mode (you can set the inspector as "debug mode" to see private fields) to see what the client inventory is set to. This might help you identify what you are setting incorrectly.
 
Hey there!
So it seemed the dialogue system integration had an issue, which has been fixed since I brought it up with Tony today. (In regards to the CurrencyOwner thing).

Now I am just strugging with this, which is not something I am sure of what is wrong.
I understand I am missing an object reference in the currencycollection script, but I am not exactly sure where that is. (same issue as Iposted above)


NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateInventorySystem.Exchange.CurrencyCollection.PotentialQuotientFor (Opsive.UltimateInventorySystem.Exchange.CurrencyCollection other) (at Assets/Opsive/UltimateInventorySystem/Scripts/Exchange/CurrencyCollection.cs:1313)
Opsive.UltimateInventorySystem.Exchange.CurrencyOwner.PotentialQuotientFor (Opsive.UltimateInventorySystem.Exchange.CurrencyCollection amount) (at Assets/Opsive/UltimateInventorySystem/Scripts/Exchange/CurrencyOwner.cs:109)
Opsive.UltimateInventorySystem.UI.Menus.Shop.ShopMenu.OnItemClicked (Opsive.UltimateInventorySystem.UI.Item.ItemViewSlotEventData slotEventData) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Menus/Shop/ShopMenu.cs:331)
Opsive.UltimateInventorySystem.UI.Item.ItemViewSlotsContainerBase+<>c__DisplayClass46_0.<Initialize>b__0 () (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Item/ItemViewSlotsContainerBase.cs:133)
Opsive.UltimateInventorySystem.UI.CompoundElements.ActionButton.Press () (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/CompoundElements/ActionButton.cs:62)
Opsive.UltimateInventorySystem.UI.CompoundElements.ActionButton.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/CompoundElements/ActionButton.cs:105)
Opsive.UltimateInventorySystem.UI.Item.ItemViewSlot.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Item/ItemViewSlot.cs:169)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/Program Files/Unity/Hub/Editor/2020.1.13f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:50)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at C:/Program Files/Unity/Hub/Editor/2020.1.13f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:261)
UnityEngine.EventSystems.EventSystem:Update() (at C:/Program Files/Unity/Hub/Editor/2020.1.13f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:376)
 
As I mentioned previously the only way I can think of that this could happen is if your player does not have a Currency Owner.

Can you make a screen shot of your player components so I can see how you have it set up.
Also send me a screenshot of the Shop again (make sure it does not have a currency owner)

The currency collection (which is the thing that is causing you issues). Is initialized in the Awake function of the CurrencyOwner. So the only other reason there could be an issue is if your player is never active before you open the shop.
 
Ok maybe I was wrong to think the issue was with the player/shop set up since everything looks good...

Is it possible you had warnings before that error and forgot to mention it?

I've looked at the code again thoroughly. I noticed that some of your error lines did not match with my code. Are you using the latest version v1.1.3?

Also is it possible you haven't set the Buy and Sell prices for your items?
To check if that's the issues replace the "GetPrice" function in the ShopMenu, I added warning logs in case it cannot find the price for an item:
Code:
/// <summary>
/// Get the price of an item amount.
/// </summary>
/// <param name="itemInfo">The item.</param>
/// <returns>The currency collection.</returns>
protected CurrencyCollection GetPrice(ItemInfo itemInfo)
{
    if (itemInfo.Item == null) {
        Debug.LogWarning("Cannot get the price of a NULL item");
        return null;
    }
    var shop = (Shop)m_Shop;
    if (m_IsBuying) {
        if (shop.TryGetBuyValueForBuyer(m_Inventory, itemInfo, ref m_TempCurrencyCollection)) {
            return m_TempCurrencyCollection;
        }
    } else {
        if (shop.TryGetSellValueForSeller(m_Inventory, itemInfo, ref m_TempCurrencyCollection)) {
            return m_TempCurrencyCollection;
        }
    }
    var buySell = m_IsBuying ? "Buy" : "Sell";
    Debug.LogWarning($"Was unable to find the {buySell} price for item: "+itemInfo);
    
    return null;
}

If that is indeed the case you need to make sure your attributes match the type "CurrencyAmounts" and the name specified in the inspector.
Note you can use the same attribute for Sell and Buy, example "Price". If you do that you must specify it in the Shop inspector.
1609835853183.png

Do let me know how you had set it up, because if that was indeed the issue I really should have had some warnings before the error saying that the attributes where missing... It would have saved you a lot of time.

And I'm sorry it took so long to figure out.
 
Ok maybe I was wrong to think the issue was with the player/shop set up since everything looks good...

Is it possible you had warnings before that error and forgot to mention it?

I've looked at the code again thoroughly. I noticed that some of your error lines did not match with my code. Are you using the latest version v1.1.3?

Also is it possible you haven't set the Buy and Sell prices for your items?
To check if that's the issues replace the "GetPrice" function in the ShopMenu, I added warning logs in case it cannot find the price for an item:
Code:
/// <summary>
/// Get the price of an item amount.
/// </summary>
/// <param name="itemInfo">The item.</param>
/// <returns>The currency collection.</returns>
protected CurrencyCollection GetPrice(ItemInfo itemInfo)
{
    if (itemInfo.Item == null) {
        Debug.LogWarning("Cannot get the price of a NULL item");
        return null;
    }
    var shop = (Shop)m_Shop;
    if (m_IsBuying) {
        if (shop.TryGetBuyValueForBuyer(m_Inventory, itemInfo, ref m_TempCurrencyCollection)) {
            return m_TempCurrencyCollection;
        }
    } else {
        if (shop.TryGetSellValueForSeller(m_Inventory, itemInfo, ref m_TempCurrencyCollection)) {
            return m_TempCurrencyCollection;
        }
    }
    var buySell = m_IsBuying ? "Buy" : "Sell";
    Debug.LogWarning($"Was unable to find the {buySell} price for item: "+itemInfo);
   
    return null;
}

If that is indeed the case you need to make sure your attributes match the type "CurrencyAmounts" and the name specified in the inspector.
Note you can use the same attribute for Sell and Buy, example "Price". If you do that you must specify it in the Shop inspector.
View attachment 4696

Do let me know how you had set it up, because if that was indeed the issue I really should have had some warnings before the error saying that the attributes where missing... It would have saved you a lot of time.

And I'm sorry it took so long to figure out.
Oh... yeah.
My CurrencyAmount attribute was called "Cost" instead of BuyPrice.. hahaha
Changing it to BuyPrice worked and got rid of the issue. Thanks!

The only issue I have left is that the game still doesn't get paused while shopping, but the shop itself actually works correctly now.
I am not sure if it may be something related to the fact that I use a dialogue system sequence in order to open the shop, but considering that the integration example works fine.. I have my doubts. I will try to bring it up with Tony anyway.
 
Hey, just wanted to say that Tony helped me out immensely with this and he updated the integration which fixed my issues.
One last thing though, you know when you buy different items from the shop and empty the NPC's inventory?
Clicking those blank shop slots also gives the Quotient error, even though there is no item supposed to be in that slot.
Any way to turn that off?
 
I don't know how I never caught that before.... it's a pretty obvious bug, super easy to fix though.

In the ShopMenu script in the OnItemClicked function added a item null check

Code:
/// <summary>
/// The event when clicking an item.
/// </summary>
/// <param name="slotEventData">The inventory grid UI.</param>
protected virtual void OnItemClicked(ItemViewSlotEventData slotEventData)
{
    if (m_OpenQuantityPickerOnItemClick == false) { return; }
    var itemInfo = slotEventData.ItemViewSlot.ItemInfo;
    if(itemInfo.Item == null){ return; }

...

You can fix it in your project, the fix will be part of the next update
 
I don't know how I never caught that before.... it's a pretty obvious bug, super easy to fix though.

In the ShopMenu script in the OnItemClicked function added a item null check

Code:
/// <summary>
/// The event when clicking an item.
/// </summary>
/// <param name="slotEventData">The inventory grid UI.</param>
protected virtual void OnItemClicked(ItemViewSlotEventData slotEventData)
{
    if (m_OpenQuantityPickerOnItemClick == false) { return; }
    var itemInfo = slotEventData.ItemViewSlot.ItemInfo;
    if(itemInfo.Item == null){ return; }

...

You can fix it in your project, the fix will be part of the next update
Hey, glad I helped you find some bugs at least. haha
Thanks for all the help. Cheers.
 
Top