Search Unity

Unity UI onDrag Image Disappearing

Discussion in 'UGUI & TextMesh Pro' started by The_Nerd_Sherpa, Mar 1, 2019.

  1. The_Nerd_Sherpa

    The_Nerd_Sherpa

    Joined:
    Dec 11, 2018
    Posts:
    57
    My drag-n-drop system is working. I can move an item from one inventory slot to another, I can swap items in slots, I can add stackable items and when the stack is full it will move to the next available slot..... All of this is working great

    ... but one problem, as soon as I click an item to begin dragging, the sprite disappears. During the drag, I am seeing the rect transform of the sprite changing with the mouse movement. So I know that I am dragging it. But there is no image rendering. As soon as I drop the item into another slot, the sprite renders again in the new slot.

    I'm not getting any console errors, and I'm not sure what to debug because the actual mechanics are working.

    I'm using Unity 2018.3.6f1
    Any thoughts on this issure are VERY welcome!
     
  2. WheresMommy

    WheresMommy

    Joined:
    Oct 4, 2012
    Posts:
    890
    Whats your script for dragging?
     
  3. The_Nerd_Sherpa

    The_Nerd_Sherpa

    Joined:
    Dec 11, 2018
    Posts:
    57
    Thanks for responding! I got it figured out now.

    I had created a "UI Camera" and put my canvas as a child object of it. I mistakenly put the UI Camera as a component of the Inventory Slot script, instead of the canvas.
     
    WheresMommy likes this.