Search Unity

Can not adding camera component to script that attached on my prefab

Discussion in 'Prefabs' started by mkcuk, Dec 16, 2019.

  1. mkcuk

    mkcuk

    Joined:
    Oct 11, 2019
    Posts:
    11
    Hello friends, I'm going to make ui buttons as move gameobjects. For this i use billboardscript for my prefab's canvas. (shown in pic.) When i open my prefab, i select canvas to add camera to attach script, the pop up window always empty. When its empty objects not look camera. I want spawn this prefab with this feature. what can i do ?



    Code (CSharp):
    1.  public Camera cam;
    2.  
    3.  
    4.     void Update()
    5.     {
    6.  
    7.         transform.LookAt(transform.position + cam.transform.rotation * Vector3.forward, cam.transform.rotation * Vector3.up);
    8.  
    9.  
    10.     }
     

    Attached Files:

    • 1PRE.png
      1PRE.png
      File size:
      199.9 KB
      Views:
      443
  2. mkcuk

    mkcuk

    Joined:
    Oct 11, 2019
    Posts:
    11
    SOLUTION : WE CANT ADD CAMERA AS I SAID. I WILL SOLVE PROBLEM LIKE :

    ADD CAMERA.MAIN WHEN OBJECT SPAWNED.