123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- using Unity.VisualScripting;
- using UnityEngine;
- using UnityEngine.UI;
- namespace Plugins.CxShine.page
- {
- public class PageManagerComp : MonoBehaviour
- {
- public static PageManagerComp singleton;
- public GameObject pageContainer;
- public string pagePrefabLocation;
- public GameObject FirstPagePrefab;
- public GameObject gameObject3dContainer;
- public GameObject debugButton;
- public string debugWindowPrefabPath;
- public void HideUI()
- {
- pageContainer.SetActive(false);
- }
- public void DisplayUI()
- {
- pageContainer.SetActive(true);
- }
- private void Awake()
- {
- gameObject.SetActive(true);
- }
- private void Start()
- {
- singleton = this;
- OpenPage(FirstPagePrefab);
- // 如果有配置调试按钮界面的话
- if (debugButton != null)
- debugButton.GetOrAddComponent<Button>().onClick.AddListener(() =>
- {
- //
- Debug.Log("打开调试页面" + debugWindowPrefabPath);
- OpenPage(debugWindowPrefabPath, true);
- });
- }
- public GameObject OpenPage(string prefabPageName, bool isShowAnim = false)
- {
- var directionLocation = pagePrefabLocation + "/" + prefabPageName;
- Debug.Log("开始打开页面:" + directionLocation);
- return OpenPage(Resources.Load<GameObject>(directionLocation));
- }
- public GameObject OpenPage(GameObject go, bool isShowAnim = false)
- {
- var newPage = Instantiate(go);
- var pageComp = newPage.GetOrAddComponent<PageComp>();
- pageComp.showAnim(isShowAnim);
- pageComp.pageName = go.name;
- // pagePanel.set parent
- newPage.transform.SetParent(pageContainer.transform, false);
- return newPage;
- }
- }
- }
|