unable to use dontdestroy on load
using UnityEngine; using System.Collections;
public class onClick : MonoBehaviour { public void Options(string optionMenu){ DontDestroyOnLoad(gameObject.GetComponent()); Application.LoadLevel (optionMenu);
}
public void Back(string mainMenu){
Application.LoadLevel (mainMenu);
DontDestroyOnLoad(gameObject.GetComponent<AudioSource>());
}
public void Highscores(string highscore){
Application.LoadLevel (highscore);
DontDestroyOnLoad(gameObject.GetComponent<AudioSource>());
}
public void VolumeControl(float volume)
{
GetComponent<AudioSource>().volume = volume;
}
i have my audiosource attached to canvas, onclick script attached to it n i wish that on changing scenes(main menu to options) audio should'nt be effected . here audio is not effected but my buttons on main menu are also displayed on options menu but according to my understanding only audiosource should remain rest everything should get destroyed...main menu buttons uses this script functions like option button uses option method..i also used awake function but all went in vein.also m using unity5.3.3 :( plz help
Answer by mahnur · Apr 15, 2016 at 11:53 AM
I called dont destroy on load first in above code in option method..but no change...i want to get only aufiosource in nect scene thats y i used getcomponent
Your answer
Follow this Question
Related Questions
Problem with Awake 2 Answers
Destroy object with dontdestroyonload 2 Answers
how to disable dontdestroyonload on a specific scene 2 Answers
Trouble with DontDestroyOnLoad 1 Answer
Dontdestroyonload breaks my scripts 0 Answers