Scene not loading in android ?!

Ok, I made a game and published on google play store, at this point all is ok…

But I made a an update changing some stuff and the result is the following :

One scene is wrong (all the rest is ok) in my phone : Level selection scene

In Unity Editor : All is working, all levels are ok and I can access them
In my phone after downloading the game a part of the scene is completely wrong like if there was an error stopping all the rest of code…

Here Is the code and the line where all seem to stop :

using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class LevelSelection : MonoBehaviour {
    public GameObject[] pack1Buttons;
    public GameObject[] pack2Buttons;
    public GameObject[] pack3Buttons;

    //public Vector3 target;
    public float levelSelectionPos = 0f;

    public Sprite[] greenbuttons;
    public GameObject panel;

    public GameObject locker;
    public GameObject skyLocker;
    public GameObject thanks;

    public Transform chooseCube;


    public int skyPackPrice;

    void Start () {

        //ZPlayerPrefs.Initialize("c4U5b8i6c5505a7d6v5e7n0t5u7r6e", "usuallyright");
        //Debug.Log(ZPlayerPrefs.GetInt("Pack1Unlocked"));
        if(ZPlayerPrefs.GetInt("SkyPACKUnlocked")==1)
        {
            Destroy(skyLocker);
        }
        if(ZPlayerPrefs.GetInt("BoxPACKUnlocked")==1)
        {
            Destroy(locker);
        }


        Vector3 pos = panel.GetComponent<RectTransform>().localPosition;
        pos.x = 427 - 927*ZPlayerPrefs.GetInt("levelSelectionPos");
        panel.GetComponent<RectTransform>().localPosition = pos;




        for(int i=0; i<=ZPlayerPrefs.GetInt("Pack1Unlocked"); i++)
        {
            pack1Buttons[i].GetComponent<Button>().interactable = true;



            pack1Buttons[i].GetComponent<Image>().sprite = greenbuttons[ZPlayerPrefs.GetInt(string.Format("1PL{0}Score", i+1))];
        }
        for(int i=0; i<=ZPlayerPrefs.GetInt("Pack2Unlocked"); i++)
        {
            pack2Buttons[i].GetComponent<Button>().interactable = true;
            pack2Buttons[i].GetComponent<Image>().sprite = greenbuttons[ZPlayerPrefs.GetInt(string.Format("2PL{0}Score", i+1))];
        }

//FROM HERE NOTHING IS WORKING



        for(int i=0; i<=ZPlayerPrefs.GetInt("Pack3Unlocked"); i++)
        {
            pack3Buttons[i].GetComponent<Button>().interactable = true;
            pack3Buttons[i].GetComponent<Image>().sprite = greenbuttons[ZPlayerPrefs.GetInt(string.Format("3PL{0}Score", i+1))];
        }
          
        GameObject cube = GameObject.Instantiate((GameObject)Resources.Load("Cubes/" + ZPlayerPrefs.GetString("CubeName")), new Vector3(0,40,-61), Quaternion.identity);
        cube.transform.SetParent(chooseCube, false);
        Destroy(cube.GetComponent<Rigidbody>());
        Destroy(cube.GetComponent<PlayerMovement>());

        cube.transform.localScale = new Vector3(70, 70, 70);
        cube.AddComponent<SlowRotation>();
        cube.GetComponent<SlowRotation>().speed = 40;
    }

What I know is that this scene is a heavy one, I have 60 buttons (more even) and 2 3D models rotating

This can come from how the scene is heavy to load or not ? If it is the case what can I do ?

Use adb logcat (google for details) and see if it is throwing any exceptions when run on the device.

It was not detecting my phone… don’t know how to solve it…

But problem solved, simply a for loop problem with array too short !
Thanks

1 Like