ViewMgr.cs 944 B

12345678910111213141516171819202122232425262728
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5. using JCUnityLib;
  6. using UnityEngine.UI;
  7. public class ViewMgr : ViewManager<ViewMgr>
  8. {
  9. protected override void OnInited()
  10. {
  11. gameObject.GetComponent<CanvasScaler>().referenceResolution = new Vector2(1920, 1080);
  12. //设置视图组
  13. SetViewGroup<HomeFrameView>(1);
  14. }
  15. //以下名称的预制体通过SceneResourceManager获取
  16. HashSet<string> scenePrefabs = new HashSet<string>(new string[] {
  17. //Home
  18. "TopBarView", "HomeView", "GameStartView", "ChallengeOptionView",
  19. "PKGameOptionView", "PKMatchView", "RoleSelectView"
  20. });
  21. protected override GameObject LoadViewPrefab(string viewName)
  22. {
  23. if (scenePrefabs.Contains(viewName)) return SceneResourceManager.Instance.GetPrefab(viewName);
  24. return base.LoadViewPrefab("Home/" + viewName);
  25. }
  26. }