I'm having some troubles with the ScreenPointToLocalPointInRectangle() function. This is my code:
void OnTouch(Vector2 position) {
Vector2 pos;
if (RectTransformUtility.ScreenPointToLocalPointInRectangle (bgImage.rectTransform, position, Camera.main, out pos)) {
pos.x = (pos.x / bgImage.rectTransform.sizeDelta.x);
pos.y = (pos.y / bgImage.rectTransform.sizeDelta.y);
}
It's not doing anything, the instructions inside the 'if' are not executed. I used Debug.Log() to check the position variable and it's fine.
How can I fix this?
Aucun commentaire:
Enregistrer un commentaire