void OnDestroy()
 {
     if (this == instance) {
         instance = null;
     }
 }
    void Awake()
    {
        scanningEnabled = scanningEnabledAtStart;

        if (instance == null) {
            instance = this;
        } else {
            Destroy(gameObject);
            return;
        }
        if (persistSceneTransitions) {
            DontDestroyOnLoad(transform.gameObject);
        }
    }