Hey. My problem depends on not properly Raycasting UI.
public void OnEndDrag(PointerEventData eventData)
{
//Code to be place in a MonoBehaviour with a GraphicRaycaster component
GraphicRaycaster gr = this.GetComponent<GraphicRaycaster>();
//Create the PointerEventData with null for the EventSystem
PointerEventData ped = new PointerEventData(null);
//Set required parameters, in this case, mouse position
ped.position = Input.mousePosition;
//Create list to receive all results
List<RaycastResult> results = new List<RaycastResult>();
//Raycast it
gr.Raycast(ped, results);
foreach (RaycastResult result in results)
{
Debug.Log("Hit " + result.gameObject.name);
}
GameObject panel = transform.Find("Panel").gameObject;
if (panel)
panel.transform.localPosition = Vector3.zero;
}
It raycasts only 1 gameobject,that one which i drag. For example if I drag BP Slot (1) and drop on BP Slot(2) it raycasts only BP Slot (1). I want to make Inventory with drag and drop system.
Strange fact is while im execute that code in void Update() it raycasts properly…
What is going on ?