- Home /
Application.LoadLevel wrong loading of Level
I want to make a level menu that connects all my scenes.
Here is my code (it is in JAVASCRIPT):
function OnMouseUp(){
if(GameObject.FindWithTag("A")){
Application.LoadLevel("Letter A");
}
else if(GameObject.FindWithTag("B")){
Application.LoadLevel("Letter B");
}
else if(GameObject.FindWithTag("C")){
Application.LoadLevel("Letter C");
}
}
so, the problems is when I click A and B it is fine but when I click the scenes from a will appear. I also tried to use the index but it is much worse. when I used the index, when i click A and B scene from letter C will load. What seems to be the problem?
Did you add them to the scene list in the Build Settings?
The action performed appears to be deter$$anonymous$$ed by what objects can be found in the scene, rather than by what object you have clicked on. Is that what is intended? As things stand, if there is an object with the tag "A" in the scene, it will always load the scene "Letter A".
It's not at all clear to me what you mean by "when I used the index". What index? Used it how?
index number from the build sir. Application.LoadLevel(); have 2 parameters right? it can be string and int/index I used both of them but same result
Answer by Joyrider · Feb 09, 2015 at 11:08 AM
Your scene has objects with all 3 tags in the scene?
Because right now you are basically loading scene A if an object with Tag A is present, same for B, same for C. So in the end... the last scene loaded is scene linked to C obviously.
You're not checking for any click recipient.
Can you help me improve my code? I tried everything I know Im just new to unity sorry
Your answer
![](https://koobas.hobune.stream/wayback/20220613182832im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
2D Animation does not start 1 Answer
Application.LoadLevel (Roguelike 2D) 2 Answers
Can I add some 3D in a 2D project? 1 Answer
2D platformer- getting errors I don't understand (c#) 1 Answer