Assignement object

Hi !

I hope that someone can resolve my problem.

In my project, I have a lot of scenes, and in each of these scenes I collect some informations, and I have one class per scene that collect information.

For exemple in the first scene I collect user’s name and email. So I have a class ID :

public class IdUser : MonoBehaviour {

    public string name;
    public string email;

   /* Some method */


And I have also a class that “don’t destroy on load” and is present in each of these scene that collect information of all scenes. Something like this :

public class SuperClass : MonoBehaviour {

   public IdUser myIdUser;

/* Some method*/

But this is my problem, when I am in my first scene (to collect IdUser) and I call this function inside mySuperClass, it doesn’t work :

public class SuperClass : MonoBehaviour {
       public IdUser myIdUser;
    public void savemyIdUser() {

    myIdUser = (IdUser) GameObject.Find("IdUser").GetComponent<IdUser>();

This method doesn’t do anything, it doesn’t assign the current object in the scene to my attribute in SuperClass.

If I print myIdUser it gives me “Null” but when I print (IdUser) GameObject.Find("IdUser").GetComponent<IdUser>();It prints the refenrece to the object.

I hope that is understandable, you can ask me question if it doesn’t.

What is your gameobject’s name which you attach IdUser script? GameObject.Find search by gameobject name. Also I did not get where you assign myUserId. Do you print myUserId or myIdUser? I did not see myUserId variable.