using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class UI_TipsForPracticePanel : BasePanel { public GameObject pptImagePrefab; public Transform content; public ScrollRect scrollRect; protected override void Awake() { base.Awake(); //pptConfig = JsonManager.LoadData("pptConfig"); } public override void ShowMe() { base.ShowMe(); } public override void HideMe() { base.HideMe(); } protected override void OnClick(string btnName) { Debug.Log(btnName); switch (btnName) { case "retrun_Btn": Bootstrap.Instance.uiManager.ShowPanel(this, E_UI_Layer.System, (panel) => { Debug.Log(".1"); Bootstrap.Instance.uiManager.HidePanel(); StartCoroutine(RefreshScrollView()); }); //Bootstrap.Instance.uiManager.HidePanel(); break; default: List textures = LoadPPTTest.LoadPPTItems(btnName); if (textures != null) { DisplayPPT(textures); } StartCoroutine(RefreshScrollView()); break; } } private void DisplayPPT(List textures) { foreach (Transform child in content) { Destroy(child.gameObject); } Debug.LogError("texturesCount:"+textures.Count); foreach (var texture in textures) { RawImage rawImage = pptImagePrefab.GetComponent(); RawImage image = Instantiate(rawImage, content); image.texture = texture; image.rectTransform.sizeDelta = new Vector2(texture.width, texture.height); } } /// /// 刷新右侧的滑动条 /// /// IEnumerator RefreshScrollView() { yield return null; // 等待一帧 LayoutRebuilder.ForceRebuildLayoutImmediate(content as RectTransform); scrollRect.verticalNormalizedPosition = 1; // 回到顶部 } }