Files
bansonic_beta_main/Assets/scripts/UI/Panel/dontdestroyonload/loadtopandbottom[Prefab.cs
T

28 lines
812 B
C#

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<Canvas>();
if (canvas != null)
{
Camera cam = Camera.main;
if (cam == null)
{
cam = FindObjectOfType<Camera>();
}
canvas.worldCamera = cam;
cam = null;
}
}
}
}