// Start is called before the first frame update void Start() { //RecreateSudokuFile(); drop_dif.GetComponent <Dropdown>().onValueChanged.AddListener(delegate { DropdownChanged(drop_dif.GetComponent <Dropdown>().value); }); //Adding text to the dropdown drop_dif.GetComponent <Dropdown>().options.Clear(); drop_dif.GetComponent <Dropdown>().options.Add(new Dropdown.OptionData() { text = "All Difficulties" }); foreach (Difficulty difficulty in (Difficulty[])Enum.GetValues(typeof(Difficulty))) { drop_dif.GetComponent <Dropdown>().options.Add(new Dropdown.OptionData() { text = difficulty.ToString() }); } btn_next.GetComponent <Button>().onClick.AddListener(delegate { ChangePage(true); }); btn_prev.GetComponent <Button>().onClick.AddListener(delegate { ChangePage(false); }); if (DataPassing.sudoku_ != null) { //This state is reached when returning to the menu from a sudoku SaveLoad.Save(DataPassing.sudoku_); DataPassing.sudoku_.VerifyAnswer(); } try { sudokus_ = SaveLoad.Load(); } catch (System.ArgumentException e) { Debug.Log(e.Message); } //Calling to the SudokuGenerator to load in the list of seeds, in preperation for generating new levels //CreateSeedFile(); SudokuGenerator.GeneratorStart(); SpawnSudoku_Levels(); //Loading difficulty selection from player prefs drop_dif.GetComponent <Dropdown>().value = PlayerPrefs.GetInt(pref_keys.selected_difficulty_int.ToString()); //Default value is 0, so the dropdownchanged method must be explicitly called in case the saved value is also 0 DropdownChanged(PlayerPrefs.GetInt(pref_keys.selected_difficulty_int.ToString())); //Loading current page from player prefs switch (PlayerPrefs.GetInt(pref_keys.selected_difficulty_int.ToString())) { default: case 0: current_page = PlayerPrefs.GetInt(pref_keys.level_page_all_int.ToString()); break; case 1: current_page = PlayerPrefs.GetInt(pref_keys.level_page_easy_int.ToString()); break; case 2: current_page = PlayerPrefs.GetInt(pref_keys.level_page_medium_int.ToString()); break; case 3: current_page = PlayerPrefs.GetInt(pref_keys.level_page_hard_int.ToString()); break; case 4: Debug.Log("PlayerPrefs has a difficulty selection saved that is not coded"); break; } //could be made into an option in the future, for now it is hard coded entries_per_line = 3; if (current_page == 0) { btn_prev.GetComponent <Button>().interactable = false; } if ((current_page + 1) * entries_per_line * entries_per_line >= in_use_sudokus_.Count) { btn_next.GetComponent <Button>().interactable = false; } //Creating and positioning the appropriate levels PositionSudoku_Levels(); }