- Home /
Switching scene problem
`I have created many scenes. two scenes named "GameOver" and "ScreenSetting". in these scenes i have made some texture with script. problem is that when i play this scene then it shows all the textures of scene but when i switch to other scene and come back to these two scene and play then no texture is displayed. whts the problem? sample code is here
function OnGUI() {
if(!soundTexture){
Debug.LogError("Assign a Sound Texture in the inspector.");
return;
}
GUI.DrawTexture(Rect((Screen.width*20)/100,(Screen.height*15)/100,(Screen.width*38)/100,(Screen.height*20)/100), soundTexture);
if(!vibrateTexture){
Debug.LogError("Assign a vibrate Texture in the inspector.");
return;
}
GUI.DrawTexture(Rect((Screen.width*21)/100,(Screen.height*43)/100,(Screen.width*38)/100,(Screen.height*20)/100), vibrateTexture);
if(!fastTexture){
Debug.LogError("Assign a fast Texture in the inspector.");
return;
}
GUI.DrawTexture(Rect((Screen.width*20)/100,(Screen.height*70)/100,(Screen.width*38)/100,(Screen.height*20)/100), fastTexture);
if (GUI.Button(Rect((Screen.width*5)/100,(Screen.height*80)/100,(Screen.width*20)/100,(Screen.height*20)/100),back,testStyle)){
Application.LoadLevel("StartScene");
Handheld.Vibrate();
}
}
`
these are the texture which i have defined in setting Scene, when I assign all the texture and play first time then it shows all the texture but when i switch to other scene and come back to setting scene then no texture appears when i play
We don't have enough information to help you, we need to see some code at least.
Answer by TrickyHandz · Oct 05, 2013 at 02:47 PM
If you are trying to maintain information assigned to varibles across a scenes you either need to call DontDestroyOnLoad() or use Static variables to store the information.
Your answer
![](https://koobas.hobune.stream/wayback/20220613115345im_/https://answers.unity.com/themes/thub/images/avi.jpg)