using UnityEngine; public class loadtopandbottomPrefab: MonoBehaviour { [Header("father obj")] public GameObject top_and_bottom_Panel; public GameObject gameobject_to_Instantiate_below; void Start() { if (top_and_bottom_Panel != null && gameobject_to_Instantiate_below != null) { GameObject instantiated = Instantiate(top_and_bottom_Panel, gameobject_to_Instantiate_below.transform); Canvas canvas = instantiated.GetComponent(); if (canvas != null) { Camera cam = Camera.main; if (cam == null) { cam = FindObjectOfType(); } canvas.worldCamera = cam; cam = null; } } } }