Drawing a GUI.Texture on mouse up at mouse position?

I am trying to drag an item from my inventory into a Rect and have the texture of that item appear wherever I let go of the mouse button within that rect. Is there a way to do this? This is the method I’ve tried but it doesn’t work:

		Rect spellCreationRect = new Rect(400, 50, 330, 360);
		if(spellCreationRect.Contains(e.mousePosition) && e.type == EventType.mouseUp && draggingItem)
		{
			GUI.DrawTexture(new Rect(e.mousePosition.x, e.mousePosition.y, 75, 75), draggedItem.itemIcon);
			draggingItem = false;
			draggedItem = null;
			print("You dragged a rune in here!");
		}

Your code is close to working. The main problem is that ‘EventType.mouseUp’ will only be true for a single frame. A simple fix would be to create a boolean and then you can do:

   Rect spellCreationRect = new Rect(400, 50, 330, 360);
   if(spellCreationRect.Contains(e.mousePosition) && e.type == EventType.mouseUp && draggingItem)
   {
     showTexture = true;
   }
   if (showTexture) {
     GUI.DrawTexture(new Rect(e.mousePosition.x, e.mousePosition.y, 75, 75), draggedItem.itemIcon);
     draggingItem = false;
     draggedItem = null;
     print("You dragged a rune in here!");
   }

I’m not sure how you manipulate ‘draggedItem.itemIcon’ in the rest of your code. You might also have to assign ‘itemIcon’ to another texture variable and use that in the DrawTexture().