Property holding reference to prefab is partially loaded

Hello,

We are trying to fix this issue for more than a half a year in our Android app:

public class Level : MonoBehaviour {
  ...
  public Tutorial startTutorial;
  public Tutorial notifTutorial;
  ...
  void Start() {
    if (!this.IsTutorialCompleted(this.notifTutorial.tutorialName))
      this.notifTutorial = Instantiate(this.notifTutorial);
  }
}

public class Tutorial : MonoBehaviour {
  ...
  public string tutorialName;
  ...
}

The GameObject holding Level is located on the scene. Both Tutorial properties are prefabs and assigned in Editor. Once scene gets loaded, the Start method gets called and IN VERY RARE cases, the property notifTutorial could be null. At the same time startTutorial is not null. Within same play session, one or two times everything is correct but on second, third time the property gets null value after scene load.

Thanks to Crashalitics, we found that notifTutorial could be null but notifTutorial.tutorialName holds the correct string value!!! How null “object”, MonoBehaviour could have not null property? We also checked and notifTutorial is null on Awake as well.

This bug causes null reference error on line with Instantiate(). Of course we can resolve this non fatal issue by adding extra IF statement but how this happens? We tried to check scene file that it is not corrupted, we tried to resave prefabs too.

Seems like this bug could be explained how reference to prefabs are stored and loaded at scene load.

Any ideas? Thanks!

I am not sure how much this is related to my case but just in case “Unity C# : custom Object is null BUT I can access its properties