Forum rules - please read before posting.

Item Combine reselects an item

edited January 2016 in Technical Q&A
Hello. Sorry me again. I have worked on this on and off all day, looked at the manual, searched, and I can't seem to find the answer even though it seems like it's maybe a stray settings problem somewhere.

When I combine two items, the combine actionlist works as expected. However, now whatever item is now in that slot is selected as the active inventory item. If the action removed the item that was there, the selected item is whatever moved into its place. Otherwise, it's the item that was acted upon. I have Reset Cursor After an Interaction checked. I can't find anything else that looks like it would do this.

Comments

  • Without screenshots, I'm I'afraid I'm not quite sure what you mean exactly.  However, you can use the Inventory: Select Action to force the deselection of the active inventory item.
  • edited January 2016
    Ok, I just checked. If I put a deselect action at the end of a combine actionlist it does deselect it, after it gets done displaying the narration message... This seems like a really hackey way to accomplish things though, to have to add a deselect inventory into every one of my combine actionlists. The inventory was working as intended yesterday. I don't know what happened to break it.

    Here is an example.

    Let's say you have three inventory items: Bat, Ball, and Doughnut. Combining bat with ball makes you hit the ball, thereby removing it from your inventory. Combining anything with Doughnut, just shows a narration message saying you can't do it. Here are some cases:

    Case 1:

    The inventory looks like this, in this order:

    Bat, Ball, Doughnut

    You combine Bat with Ball. Ball is removed from the inventory and Doughnut is the selected inventory item.

    Case 2:

    The inventory looks like this, in this order:

    Ball, Bat, Doughnut

    You combine Bat with Ball. Ball is removed from the inventory and Bat is the selected inventory item.

    Case 3:

    The inventory looks like this, in this order:

    Ball, Bat, Doughnut

    You combine Bat with Doughnut. The message is displayed and Doughnut is now the selected inventory item.

    What I would like to happen is that after any combine actionlist is run that no inventory items are selected at all. I guess it would be kind of ok if the one you just used was selected, but as it is, it's either the thing you just used the item ON or some random item that moved into the slot of the thing you just used the inventory item on.

    I'm not sure a screen shot would help explain. I suppose I could make a video if it's still not clear.

  • Here's a video of the problem:
  • I found what caused the problem, but still don't know how to properly fix it. I changed from AC Inventory Menu to Unity Prefab Inventory UI and that's when the problem started. Just using the prefab that came with AC with one minor change though: one additional panel that doesn't even do anything.

    Have a temporary fix for now switched back to AC Inventory Menu and added a canvas with my one panel separately into the scene. That's such a dirty way to go about it, though.
  • You would put the Deselect Action at the front of the ActionList - but it was only a temporary solution.

    It looks like your ActionLists are set to Run In Background - does the problem go away if you set them instead to Pause Gameplay?

    I've followed your steps, but it actually works fine for me.  Are you using the latest version of AC?
  • edited January 2016
    I was using 1.48b. I just now upgraded it to 1.50c but I don't know if that fixes the original issue because it causes other issues that make it so I can't get to the original Issue.

    Here is what all relevant versions:
    AC - 1.50c
    Unity - 5.3.1f1
    UFPS - 1.5.2

    There are two new issues with inventory since updating.

    1. No matter if I use AC or Unity UI Prefab, the cursor jumps to the center of the screen upon clicking on any inventory item. This tells me that it's locking the cursor temporarily for some reason and then unlocking again.

    2. When using Unity UI Prefab, inventory selection doesn't work at all. Click the inventory item, the cursor jumps to the center of the screen, nothing is selected or used.

    -------------------------------------------------------------------------------------------------

    Incidentally, and this has nothing whatsoever to do with this other problem, but was reminded of it when 1.5 replaced the script change I made to fix it. When cycling the cursor while an inventory item is selected, it throws an error in PlayerCursor.cs details below

    ArgumentOutOfRangeException: Argument is out of range.
    Parameter name: index
    System.Collections.Generic.List`1[AC.CursorIcon].get_Item (Int32 index) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
    AC.PlayerCursor.CycleCursors () (at Assets/AdventureCreator/Scripts/Controls/PlayerCursor.cs:682)
    AC.PlayerCursor.UpdateCursor () (at Assets/AdventureCreator/Scripts/Controls/PlayerCursor.cs:119)
    AC.StateHandler.Update () (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:234)

    I fixed this by simply commenting out the code on lines 682-698 and just replacing it with:

    if (selectedCursor >= KickStarter.cursorManager.cursorIcons.Count || selectedCursor < 0)
    {
        selectedCursor = -1;
    }

    Of course, that removes some functionality, but it is functionality I personally don't need.

    Anyway, just pointing that out in case you're interested.
  • Thank you for the error details - I'll look into them.

    v1.50 changes the UFPS integration workflow - have you amended your player prefab?  There's nothing that I can think of on the AC side of things that would cause the cursor to lock/unlock like that, unless ToggleCursor was somehow mapped to your mouse button.  If you temporarily use a non-UFPS player, does it then behave correctly?
  • edited January 2016
    Well, some good news and one issue left.

    1. The mouse jump was indeed UFPS's doing. That is taken care of.

    2. The Unity UI Prefab does not completely not work as I previously thought, the inventory buttons are just very.... insensitive. You have to hold down the mouse button over them for a second before they register that they were clicked. This only happens on the Unity UI Prefab, not in the AC version, and not with any hotspot interactions or anything. It is the same way when using the tinpot AC player prefab.

    3. Now that the Prefab menu works (kind of) I can announce that the original reselecting issue is now gone after the update!

    So.... there's the issue with number 2 though. Would could possibly be going on here....
  • AC doesn't do any kind of click-handling-overriding for Unity UI - it just adds events to the buttons for you.  If there's a delay of some kind, the presumtion would have to be that it's on the Unity side of things.  Are you using drag-and-drop, and do you get similar delays when clicking on e.g. the Unity UI default Pause menu?
  • edited January 2016
    Actually, AC does implement a Click Handler. It adds a script to each of the inventory buttons called "UI Slot Click" which Implements IPointerClickHandler. This script appears to only handle right clicks, however. Right clicks do work immediately and without issue.

    It does not add any On Click events to the button that I can see in the inspector. When I did add a test event there that just changes the label of a Text element, that does always work immediately even when the inventory action fails to work because I did not hold the mouse button down long enough.

    To tell you the truth, I have no idea why the inventory buttons work at all. I can see nothing that handles left clicks. Yet, if you hold the button down for a second, it does work. This is intermittent though, as sometimes it works immediately, and other times not, seemingly randomly.

    I am not using drag and drop. It seems to happen on most if not all UI
    Prefab menus. UIs I make myself in the scene work without issue.



  • Left-clicks are automatically added as events inside an element script's LoadUnityUI function.  In MenuInventoryBox.cs, the listener is added on line 125.  Unfortunately, I cannot recreate your issue - again, does removing UFPS from the equation have any effect?
  • edited January 2016
    Am using the tinpot AC prefab, removed UFPS player from the scene.

    So, ProcessClickUI is what was causing it. If I bypass that and just call ProcessClick instead, it works fine. I'm not really sure why.
  • ProcessClickUI looks to be doing some check to see if the player is allowed to click. However, it often comes to the wrong conclusion it seems.

    So, what I've done for the moment is comment out that if block in ProcessClickUI so it always runs the code inside it. That seems to be the easiest thing to change back if there is a better solution.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.