I'm assuming by "x=0, y=0", you mean the center of the canvas. Given that you want to set the object's position relative to another object that is not its direct parent, you will have to do some tricks.
The easiest way is to parent the object to the canvas, set its anchoredPosition to (0, 0, 0), then parent it back to its original parent:
public class Test : MonoBehaviour
{
[SerializeField] private Canvas canvas;
[SerializeField] private Transform parent;
private RectTransform rectTransform;
private void Start()
{
rectTransform = GetComponent<RectTransform>();
transform.SetParent(canvas.transform);
rectTransform.anchoredPosition = Vector3.zero;
transform.SetParent(parent);
}
}
The harder (and probably better) way is to calculate the canvas's coners' position in world space using GetWorldCorners(), then set the object's position accordingly:
public class Test : MonoBehaviour
{
[SerializeField] private Canvas canvas;
private void Start()
{
Vector3[] canvasCorners = new Vector3[4];
canvas.GetComponent<RectTransform>().GetWorldCorners(canvasCorners);
// Here I'm using the middle point of the bottom-left and top-right corner to set the position
transform.position = (canvasCorners[0] + canvasCorners[2]) / 2;
}
}