unity dontdestroyonreload code example
Example 1: dontdestroyonload unity
DontDestroyOnLoad(this.gameObject);
Example 2: unity dontdestroyonload
private void Awake(){
if(instance == null){
instance = this;
DontDestroyOnLoad(instance);
}
else{
Destroy(gameObject)
}
}