Define local position offset without a parent

Hi All,

I’m trying to get a world space UI canvas set up for VR.

I basically want to say to the canvas:

  1. Match the rotation of the current camera (using euler angles)
  2. Match the position of the current camera
  3. Offset the position in the forward (Z) direction by x units

But for the life of me I can’t seem to get it working. I’d rather not nest the canvas as a child under the camera as I have multiple cameras that can be switched between and I don’t want to have to keep swapping parents around.

Is there an elegant way of doing this? So far my code is dead simple:

    public GameObject positionObject;
    public GameObject rotationObject;


    // Update is called once per frame
    void Update () {

        //print(positionObject.transform.position);

        this.transform.eulerAngles = rotationObject.transform.eulerAngles;
        this.transform.position = positionObject.transform.position;

I’m just not sure what the next step would be to set up a local offset to the positionObject.

Thanks!