请问一下Unity如何按照图中的代码撰写背景可以往后的代码

图片说明图片说明

这是背景往前的代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BackgroundCollectorL : MonoBehaviour
{
float width;
// Start is called before the first frame update
void Start()
{
width = GameObject.FindGameObjectWithTag("BG").GetComponent().size.x;
}

private void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "BG")
{
Vector2 temPos = other.transform.position;
temPos.x += width * 2;
other.transform.position = temPos;
}
}
}