title: Getting error with creating objects in Unity
body: <p>I have an error in the script. At first, when the program starts, everything is fine, all InputFields have coordinates Y -200. But when I delete objects, and then re-create already the Y coordinate -800.</p>
  <p>Where is the error?</p>
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using UnityEngine.UI;
  
  public class SpawnText : MonoBehaviour
  {
  public int text_number = 20;
  public GameObject TextPanel;
  public GameObject toggle;
  public GameObject ct;
  private int k;
  public GameObject[] obj;
  public GameObject[] obj1;
  public GameObject textTime;
  public GameObject textPrice;
  public GameObject InputFieldTime;
  public GameObject InputFieldPrice;
  private RectTransform rt;
  private bool isSettings = false;
  
  // Start is called before the first frame update
  void Start()
  {
      CreateProgram();
  }
  // Update is called once per frame
  
  //Клик на кнопку настроек
  public void SettingsOnClick()
  {
      switch (isSettings)
      {
          case false:
              isSettings = true;
              textTime.SetActive(false);
              textPrice.SetActive(false);
              InputFieldTime.SetActive(false);
              InputFieldPrice.SetActive(false);
              for(int i = 0;i &lt; text_number; i++)
              {
                  Destroy(obj[i]);
                  Destroy(obj1[i]);
              }
              break;
          case true:
              isSettings = false;
              textTime.SetActive(true);
              textPrice.SetActive(true);
              InputFieldTime.SetActive(true);
              InputFieldPrice.SetActive(true);
              CreateProgram();
              break;
      }
  
  
      }
  
  private void CreateProgram()
  {
      rt = ct.GetComponent&lt;RectTransform&gt;();
      int height;
      k = -60;
      height = text_number * 72;
      rt.sizeDelta = new Vector2(0, height);
  
      for (int i = 0; i &lt; text_number; i++)
      {
  
  
          obj[i] = Instantiate(TextPanel, new Vector2(0, 0), Quaternion.identity) as GameObject;
          obj1[i] = Instantiate(toggle, new Vector2(0, 0), Quaternion.identity) as GameObject;
  
          obj[i].transform.SetParent(ct.transform);
          obj1[i].transform.SetParent(ct.transform);
  
          obj[i].transform.localPosition = new Vector2(-200, k);
          obj1[i].transform.localPosition = new Vector2(-420, k);
  
          k -= 70;
          obj[i].transform.localScale = new Vector2(1, 1);
          obj1[i].transform.localScale = new Vector2(1, 1);
          obj1[i].GetComponentInChildren&lt;Text&gt;().text = (i + 1).ToString();
      }
  }
  }
  </code></pre>
  <p>When program starts</p>
  <p><a href="https://i.stack.imgur.com/qRMjO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qRMjO.png" alt="" /></a></p>
  <p>When delete and create objects</p>
  <p><a href="https://i.stack.imgur.com/W2DXk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W2DXk.png" alt="" /></a></p>