- Home /
Can't access other game object in build-ed version of the game but when testing in editor it works alright
So I have start button with code:
GameControlScr gameControlScr;
void Start () {
gameControlScr = GameObject.Find ("GameControl").GetComponent<GameControlScr>();
}
void OnMouseDown()
{
gameControlScr.testMethod();
}
When I test it from unity editor it works fine. It calls testMethod() and new scene is loaded. But when I build project into android or pc versions it won't call this method. It seems like it can't access gameControlScr. I also tried making gameControlSrc a static reference and it won't work as well. Btw testMethod() just have this line of code:
public void testMethod(){
Application.LoadLevel("Test01Level01");
}
Check the output.log file in your build directory for any errors.
Answer by KayelGee · Oct 06, 2014 at 11:40 AM
Make sure you have added all your scenes to the build. You can do this by either going into the "Build Settings" and clicking on "Add Current" to add the current scene or by draging and droping your scenes into the Build Settings. For further information look here
Your answer
![](https://koobas.hobune.stream/wayback/20220613164447im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Variables correct in editor, But being reset in build? 0 Answers
Run signed apk 2 Answers
A node in a childnode? 1 Answer
How do I extract the Unity version used to build 1 Answer
Distribute terrain in zones 3 Answers