I made this function that I use to pop up some buttons over and object when the player clicks on it.
public virtual void popUp(Vector3 position)
{
setActive(true); //Set the canvas that contains the menu to "active"
Vector2 pos = Camera.main.WorldToScreenPoint(position);
Debug.Log(pos);
menu.transform.position = pos;
Debug.Log(menu.transform.position);
}
It is quite simple and works fine… Except for the very first call. When it is first called, the transform’s position remains (0,0,0) event when the pos variable printed the correct position the line before.
Anyone knows what can prevent the transform to update its position ?