Hello All,
I’m trying to figure out how the best way to go about writing a drag and drop inventory system. This would be used for dropping items into the 3D world and switching slots in the inventory. This is some very basic code of what I’m trying to do. I don’t know how the rest of the Unity gui works with drag and drop, so I’m forced to use Gui element. Problem is that is drawn behind Unity3D GUI Elements in AutoLayout, and Manual Layout. Unity GUI doesn’t seem to handle drag and drop elements, but it does allow you to change the depth.
How do I properly change the draw depth of the GUI Element?
public class Drag_and_Drop_Handler : MonoBehaviour {
public static int Gui_Depth = -8;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnMouseDrag(){
guiTexture.pixelInset = new Rect (Input.mousePosition.x, Input.mousePosition.y - guiTexture.pixelInset.height, guiTexture.pixelInset.width, guiTexture.pixelInset.height);
}
void OnGUI(){
GUI.depth = Gui_Depth;
}
}