Search Unity

How to gameobject.findwithtag tilemap in a different scene?

Discussion in '2D' started by Pixitales, Jul 21, 2019.

  1. Pixitales

    Pixitales

    Joined:
    Oct 24, 2018
    Posts:
    227
    My scene has 2 scenes. My camera is on the first scene and my tilemap is on the second scene. How do I reference my tilemap to my camera inspector across scenes?

    Doesn't work
    Code (CSharp):
    1. public class CameraFollow : MonoBehaviour
    2. {
    3.     [SerializeField]
    4.     private Tilemap tilemap;
    5.  
    6.     private void Awake()
    7.     {
    8.         Tilemap tilemap = (Tilemap)FindObjectOfType(typeof(Tilemap));
    9.     }
    10. }