using SimpleJSON; using System; using System.Collections.Generic; using System.Reflection; using TMPro; using UnityEngine; using UnityEngine.UI; using WS; [ObjectSystem] public class MainMenuControllerUpdateSystem : UpdateSystem { public override void Update(MainMenuController self) { self.Update(); } } public class MainMenuController : Controller { List courses = new List { CoursType.中药检索, CoursType.中药学古文献, CoursType.药物采集, CoursType.药物炮制, CoursType.药物化学, CoursType.药物药理, CoursType.中药药剂, CoursType.中药资源与鉴定, CoursType.中药质量控制与分析, CoursType.药事管理法规, CoursType.中医药方剂 }; protected override void BindingViewModel() { _Model.currentPageIndex.Value = 1; refreshCourseList(); ToggleGroupAddListener(); _Model.Bind(_View.nextPageBtn,NextBtnClick); _Model.Bind(_View.lastPageBtn, LastBtnClick); } public override void OpenView() { base.OpenView(); } public void Update() { if (_Model.currentPageIndex.Value == Math.Ceiling((double)courses.Count / 6)) { _View.nextPageBtn.interactable = false; } else { _View.nextPageBtn.interactable = true; } if (_Model.currentPageIndex.Value == 1) { _View.lastPageBtn.interactable = false; } else { _View.lastPageBtn.interactable = true; } } void NextBtnClick() { _Model.currentPageIndex.Value++; refreshCourseList() ; } void LastBtnClick() { _Model.currentPageIndex.Value--; refreshCourseList() ; } void refreshCourseList() { ReferenceCollector[] rcArray = _View.group.GetComponentsInChildren(); for (int i = 0; i < rcArray.Length; i++) { int courseIndex = (_Model.currentPageIndex.Value - 1)*6+i; if (courseIndex>=courses.Count) { rcArray[i].GetComponent().alpha = 0; } else { rcArray[i].GetComponent().alpha=1; rcArray[i].GetComponent("Index").text = courseIndex.ToString(); rcArray[i].GetComponent("CourseName").text = courses[courseIndex].ToString(); } } } void ToggleGroupAddListener() { Toggle[] toggles = _View.group.GetComponentsInChildren(); for (int i = 0; i < toggles.Length; i++) { var index = i; var rc = toggles[index].GetComponent(); rc.GetComponent