Search Unity

Drag and drop script and ui layers

Discussion in 'Scripting' started by Phobiegames, Feb 17, 2018.

  1. Phobiegames

    Phobiegames

    Joined:
    Apr 3, 2017
    Posts:
    113
    So I'm using a basic event handler script to simulate a drag and drop system with my inventory slot items. Which works fine, however each inventory slot prefab isn't on the same sorting layer because of how unity sorts ui based on their spot in the hierarchy. So when i go to drag an item, it is behind all the other slots rather than in front. Any ideas? I did a little bit of research and have been seeing people use the canvas layout component but when i tried adding it to my slots, my dragging script stopped working.

    EDIT: I have solved this post myself by adding a canvas component to each slot and setting the sorting layer while added a graphics raycaster component.
     
    Last edited: Feb 17, 2018
  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
  3. xHydra9

    xHydra9

    Joined:
    Dec 18, 2022
    Posts:
    1
    Thanks god! Really appreciate ur edit message.