1using NaughtyAttributes;
2using System.Collections.Generic;
13 private int pageIndex = 0;
14 private int maxPages = 0;
15 private int selected = -1;
20 var hasMoreThenThree =
false;
22 if (user.HasValue && user.Value.addedTrainings !=
null)
26 for (
int i = 0; i < user.Value.addedTrainings.Count; i++)
32 hasMoreThenThree = user.Value.addedTrainings.Count > 3;
33 maxPages = user.Value.addedTrainings.Count / 3 + 1;
38 item.gameObject.SetActive(hasMoreThenThree);
44 if (selected == -1)
return;
45 var jsonPath = GetFilesFullPath(
new [] {
buttonTexts[selected].text});
46 Debug.Log(
"jsonPath: " + jsonPath.FirstOrDefault());
47 var mls = FindObjectOfType<MenuLoadScene>();
48 mls.Open(jsonPath[0]);
54 Debug.Log(
"SELECTED: " + index);
67 pageNumber.text = $
"{pageIndex + 1}/{maxPages}";
70 var trainings = user.Value.addedTrainings;
72 for (
int i = pageIndex * 3; i < trainings.Count; i++)
83 if (pageIndex > maxPages - 1)
89 pageNumber.text = $
"{pageIndex + 1}/{maxPages}";
92 var trainings = user.Value.addedTrainings;
94 for (
int i = pageIndex * 3; i < trainings.Count; i++)
113 private List<string> GetFilesFullPath(
string[] files,
114 SearchOption searchOption = SearchOption.AllDirectories)
117 string fileName = Path.Combine(Application.streamingAssetsPath,
"..",
"..");
119 string fileName = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
121 Debug.Log(
"fileName: " + fileName);
122 Debug.Log(
"filePath: " + Path.GetDirectoryName(fileName));
123 var allfiles = Directory.EnumerateFiles(Path.GetDirectoryName(fileName),
"*", searchOption).ToList();
124 var retval =
new List<string>();
125 foreach (var filepath
in allfiles)
127 foreach (var file
in files)
129 if (filepath.EndsWith(file))
131 retval.Add(filepath);
UnityEngine.UI.Button Button
UnityEngine.UI.Text pageNumber
GameObject[] pageswitchers
void SelectCourse(int index)
UnityEngine.UI.Text[] buttonTexts