How to spawn prefabs by xMin and xMax position which will change the xmin and xmax position by it self when the screen size is changed?

Hello

i attached the below script to an empty gameobject for spawning prefabs it works fine but the only problem is that i don’t know how to set xMin and xMax position that will be able to change by it self xMin and xMax position when the screen size is changed.

Note: some prefabs are having circleCollider, and some of them BoxCollider.

thank you in advance!!!

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class SpawningColors : MonoBehaviour 
{
	public GameObject[] ColorSprites;
	

	public float delayTimer = 0.5f;
	public float xMaxPosition, xMinPosition;

	private float timer;

    private int colorObjectNumbers;


    // Use this for initialization
    void Start () 
	{
        timer = Time.deltaTime;
	}
	
	// Update is called once per frame
	void FixedUpdate ()
	{
		Spawning ();

	}
	public void Spawning ()
	{
		timer = timer - Time.deltaTime;
		if (timer <=0)
		{
			Vector3 scale = ColorSprites[colorObjectNumbers].transform.localScale;
			float rndmScale = Random.Range (0.8f, 1f);
			scale = new Vector3 (rndmScale, rndmScale, rndmScale);
			ColorSprites[colorObjectNumbers].transform.localScale = scale; // assign the new scale.



			Vector3 colorObjectPos = new Vector3 (Random.Range(xMinPosition, xMaxPosition),transform.position.y, transform.position.z );
			colorObjectNumbers = Random.Range(0, 24);
			Instantiate(ColorSprites[colorObjectNumbers], colorObjectPos, transform.rotation);

			timer = delayTimer;
		}
	}
}

I use similar solution but find answered already so:

How do i check if the screen/GameWindow has changed size?

I find the solution by finding the left and right edges of camera and it works good

here is the updated code

using UnityEngine;
 using UnityEngine.UI;
 using System.Collections;
 
 public class SpawningColors : MonoBehaviour 
 {
     public GameObject[] ColorSprites;
     
 
     public float delayTimer = 0.5f;
     public float xMaxPosition, xMinPosition;
 
     private float timer;
 
     private int colorObjectNumbers;
 
 
     // Use this for initialization
     void Start () 
     {
         float camDistance = Vector3.Distance(transform.position, Camera.main.transform.position);
      
        rightBorder = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, camDistance)).x;
        leftBorder = clampCamera.ViewportToWorldPoint(new Vector3(1, 0, camDistance)).x;

        timer = Time.deltaTime;
     }
     
     // Update is called once per frame
     void FixedUpdate ()
     {
         Spawning ();
 
     }
     public void Spawning ()
     {
         timer = timer - Time.deltaTime;
         if (timer <=0)
         {
             Vector3 scale = ColorSprites[colorObjectNumbers].transform.localScale;
             float rndmScale = Random.Range (0.8f, 1f);
             scale = new Vector3 (rndmScale, rndmScale, rndmScale);
             ColorSprites[colorObjectNumbers].transform.localScale = scale; // assign the new scale.
 
 
 
             Vector3 colorObjectPos = new Vector3 (Random.Range(leftBorder, 
             rightBorder),transform.position.y, transform.position.z );
        
             colorObjectNumbers = Random.Range(0, 24);
             Instantiate(ColorSprites[colorObjectNumbers], colorObjectPos, transform.rotation);
 
             timer = delayTimer;
         }
     }
 }