use the size of the object as an offset

I am making a unity game and I have a script that runs off of 2 others, public class spawner is the one in question, basically I have a UI scroll view with a bunch of different objects and when you click on one you spawn it with the spawner. I am trying to get the size of each unit as they spawn so that it can be offset to be right next to the initial object. This is how I have the spawner code now and I am getting an error of Assets\spawner.cs(15,18): error CS1501: No overload for method ‘GetComponent’ takes 1 arguments I had help with the codes because I am fairly new to coding.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

 public class UnitToggle : MonoBehaviour
 {
        // Drag & drop the gameObject with the `UnitToggleGroup` component (see below)
     public UnitToggleGroup unitToggleGroup;
     public GameObject unit;
     public event System.Action<GameObject> ObjectOpened;

     public int offset;

     
 
     void Start()
     {
         unitToggleGroup.Add(this);
         
     }
 
     public void OpenObject()
     {
         if (unit != null)
         {
             unit.SetActive(true);
             ObjectOpened?.Invoke(unit);
         }
     }
     public void CloseObject()
     {
         if (unit != null)
             unit.SetActive(false);
     }
 }  

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

  public class UnitToggleGroup : MonoBehaviour
 {
 
     private List<UnitToggle> toggles = new List<UnitToggle>();
     public GameObject SelectedUnit { get ; private set ; }
     public void Add(UnitToggle toggle)
     {
         if(toggles.Contains(toggle))
             return;
 
         toggles.Add(toggle);
         toggle.ObjectOpened += (GameObject unit) => OnObjectEnabled(toggle, unit);
     }
     public void OnObjectEnabled(UnitToggle selectedToggle, GameObject unit)
     {
         foreach(UnitToggle toggle in toggles)
         {
             if(toggle != selectedToggle)
                 toggle.CloseObject();
         }
         SelectedUnit = unit;
     }
 }

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

public class spawner : MonoBehaviour
 {
     public UnitToggleGroup unitToggleGroup;
     public Transform[] spawnLocations;

     public int offset;

    
    public void Start() {
        offset = GetComponent<Renderer>(unitToggleGroup.SelectedUnit);
    }
     public void SpawnCurrentlySelectedUnit()
     {
        //offset = GetComponent<SelectedUnit>;

        //   offset = GetComponent<Renderer>(UnitToggleGroup.SelectedUnit);

         if(unitToggleGroup.SelectedUnit != null){
             
             GameObject unit = Instantiate(unitToggleGroup.SelectedUnit, spawnLocations[Random.Range(0, spawnLocations.Length + offset)].transform.position , Quaternion.Euler(0,180,0))  as GameObject;
         }
     }
 }

The error you are having specifically is an incorrect usage of GetComponent(). It seems like what you mean to do is get the renderer component from the selected unit, in which case you want to call

Renderer selectedRenderer = unitToggleGroup.SelectedUnit.GetComponent<Renderer>();

However I’m not really sure what the “offset” variable is supposed to be (you are using it with random.range to index into a list of spawn locations?) If you want the size of the object, I suppose you can look at the renderer’s bounds property, although depending on exactly what you are doing this may not be what you want. If you can give a very specific description of what you want the behavior of the spawner to be, I could be more specific on how to actually go about doing it, but I’ll admit I am a little confused by what you are trying to do.