- Home /
Question by
Naserano · Sep 25, 2011 at 03:04 PM ·
audiosourcelevelmusicdonotdestroy
Is there any way to destroy script at certain level ?
As the title says, is there any way to destroy script at certain level ?
the script that I need to destroy is "DoNotDestroyOnLoad" !!
I attached it to empty gameObject that contains audio source and I want to stop the music if the player reaches level "whatever" !
Please help me, this is so important for me !!!
Comment
Best Answer
Answer by unluckyBastard · Sep 25, 2011 at 03:07 PM
Add this to it
var levelName : String = "levelone"; // change this obviously...
function Start(){
if(Application.loadedLevelName == levelName ){
Destroy(this);
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612223912im_/https://answers.unity.com/themes/thub/images/avi.jpg)