Hello.
I have an invisible UI Panel which is streched over canvas and has OnPointerUp
method.
It has anchors like this:
I want to instantiate prefabs inside this UI panel which has its own anchor attributes:
I want to capture pointers position and instantiate there my UI prefab as my panels child like this:
public void OnPointerUp(PointerEventData pointer)
{
GameObject newUIElement = Instantiate(myprefab) as GameObject;
newUIElement.transform.SetParent(invisibleParentPanel.transform);
RectTransform rect = (RectTransform)newUIElement.transform;
rect.position = pointer.position
}
My new UI element has very big coordinates which places it far outside. Is there I need to add some new calculations?