I made a scene where all the levels of the game are displayed, for this I made a script where I create a list of all the scenes (levels) that are filled through the inspector ( https://prnt.sc/n96sy0 ).
Each element of the list is a prefab, a button with text, the text is the name of the scene. Uses standard Scroll View ( https://unity3d.com/ru/learn/tutorials/topics/user-interface-ui/scroll-view ).
The problem is that the android does not display a list of levels, although the editor itself has all the rules. On the 1st screen, running scene.
Through Unity Remote all the rules.
Here is a screen from the phone, it displays only 1 default prefab - https://prnt.sc/n96x7k
The code that runs when the scene loads:
public class ListScenes : MonoBehaviour { public GameObject viewLevel; //Префаб, который отображается в content public List<Object> scenes; //Список сцен private GameObject content; //Объект, в который будут добавляться префабы void Start() { content = Helper.FindInChildren(gameObject, "Content"); addScenesToList(); } private void addScenesToList() { foreach (Object scene in scenes) { GameObject obj = Instantiate(viewLevel, content.transform); //Создаю префаб и кидаю его в content Helper.FindInChildren(obj, "Text").GetComponent<Text>().text = scene.name; //Ищу в своем префабе компонент Text и меняю текст на название сцені obj.GetComponent<Button>().onClick.AddListener(() => { SceneManager.LoadScene(scene.name, LoadSceneMode.Single); }); //Вешаю свой обработчик нажатия } } }
The latest version of Unity.
Or maybe someone has other ideas, how to display a list of levels?
Help me please)