From 20855f01c08d53fd2d06db5843fada6a4f6e4fba Mon Sep 17 00:00:00 2001 From: taosuqi <2274240467@qq.com> Date: Fri, 11 Apr 2025 16:02:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9ppt=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=EF=BC=88=E7=82=B9=E4=B8=80=E4=B8=AA=E5=8A=A0=E8=BD=BD=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UI/UIPanel/UI_TipsForPracticePanel.prefab | 2 +- Assets/Scripts/Bootstrap.cs | 7 +-- Assets/Scripts/Test/LoadPPTTest.cs | 58 +++++++++---------- .../UI/UIPanel/UI_TipsForPracticePanel.cs | 16 ++--- 4 files changed, 38 insertions(+), 45 deletions(-) diff --git a/Assets/Resources/UI/UIPanel/UI_TipsForPracticePanel.prefab b/Assets/Resources/UI/UIPanel/UI_TipsForPracticePanel.prefab index cfd60f9..fab3925 100644 --- a/Assets/Resources/UI/UIPanel/UI_TipsForPracticePanel.prefab +++ b/Assets/Resources/UI/UIPanel/UI_TipsForPracticePanel.prefab @@ -64,7 +64,7 @@ MonoBehaviour: m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 1, g: 1, b: 1, a: 0} - m_RaycastTarget: 1 + m_RaycastTarget: 0 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 m_OnCullStateChanged: diff --git a/Assets/Scripts/Bootstrap.cs b/Assets/Scripts/Bootstrap.cs index 1b92578..cde1b15 100644 --- a/Assets/Scripts/Bootstrap.cs +++ b/Assets/Scripts/Bootstrap.cs @@ -19,8 +19,8 @@ public class Bootstrap : SingletonMono eventCenter = new EventCenter(); scenesManager = new ScenesManager(this); pptFolderName = Application.streamingAssetsPath + "/PPT"; - //LoadPPTTest.PPTFiles(pptFolderName); - //ppts = LoadPPTTest.PPTName(); + LoadPPTTest.PPTFiles(pptFolderName); + ppts = LoadPPTTest.PPTName(); DontDestroyOnLoad(gameObject); } @@ -33,10 +33,9 @@ public class Bootstrap : SingletonMono { uiManager.ShowPanel(this, E_UI_Layer.Bot, (panel) => { - //LoadPPTTest.PPTFiles(pptFolderName); uiManager.ShowPanel(this, E_UI_Layer.Top, (panel) => { - //ppts = LoadPPTTest.PPTName(); + Debug.Log("UI_SelectModePanel"); }); }); diff --git a/Assets/Scripts/Test/LoadPPTTest.cs b/Assets/Scripts/Test/LoadPPTTest.cs index 10d127a..e2710c5 100644 --- a/Assets/Scripts/Test/LoadPPTTest.cs +++ b/Assets/Scripts/Test/LoadPPTTest.cs @@ -80,44 +80,38 @@ public static class LoadPPTTest /// 获取文件夹下所有.pptx文件 /// /// - public static async void PPTFiles(string folderPath) + public static void PPTFiles(string folderPath) { string fullPPTFolderPath = Path.Combine(Application.streamingAssetsPath, folderPath); pptsPath = Directory.GetFiles(fullPPTFolderPath, "*.pptx"); - for (int i = 0; i < pptsPath.Length; i++) - { - string pptName = PathName(pptsPath[i]); - await UniTask.Yield(); - await LoadAllPPTFiles(pptName, pptsPath[i]); - } } - public static async UniTask LoadAllPPTFiles(string pptName, string folderPath) - { - List texture2Ds = new List(); - Presentation presentation = new Presentation(folderPath); - // 遍历文档(只做示例使用自己根据需求拓展) - for (int i = 0; i < presentation.Slides.Count; i++) - { - await UniTask.Yield(); - ISlide slide = presentation.Slides[i]; - var bitmap = slide.GetThumbnail(1f, 1f); - // 声明内存流,将图片转换为内存流,再由流转换为byte数组,然后用texture2d加载byte数组 - using (MemoryStream ms = new MemoryStream()) - { - bitmap.Save(ms, ImageFormat.Jpeg); - byte[] buff = new byte[ms.Length]; - ms.Seek(0, SeekOrigin.Begin); - await ms.ReadAsync(buff, 0, (int)ms.Length); - Texture2D texture2D = new Texture2D(2, 2); - texture2D.LoadImage(buff); - texture2Ds.Add(texture2D); - } - } - texturesDic.Add(pptName, texture2Ds); - Debug.Log("所有PPT加载完成!"); - } + //public static async UniTask LoadAllPPTFiles(string pptName, string folderPath) + //{ + // List texture2Ds = new List(); + // Presentation presentation = new Presentation(folderPath); + // // 遍历文档(只做示例使用自己根据需求拓展) + // for (int i = 0; i < presentation.Slides.Count; i++) + // { + // await UniTask.Yield(); + // ISlide slide = presentation.Slides[i]; + // var bitmap = slide.GetThumbnail(1f, 1f); + // // 声明内存流,将图片转换为内存流,再由流转换为byte数组,然后用texture2d加载byte数组 + // using (MemoryStream ms = new MemoryStream()) + // { + // bitmap.Save(ms, ImageFormat.Jpeg); + // byte[] buff = new byte[ms.Length]; + // ms.Seek(0, SeekOrigin.Begin); + // await ms.ReadAsync(buff, 0, (int)ms.Length); + // Texture2D texture2D = new Texture2D(2, 2); + // texture2D.LoadImage(buff); + // texture2Ds.Add(texture2D); + // } + // } + // texturesDic.Add(pptName, texture2Ds); + // Debug.Log("所有PPT加载完成!"); + //} public static List LoadAllPPTFiles(string folderPath) { diff --git a/Assets/Scripts/UI/UIPanel/UI_TipsForPracticePanel.cs b/Assets/Scripts/UI/UIPanel/UI_TipsForPracticePanel.cs index 7ed2841..966b9cf 100644 --- a/Assets/Scripts/UI/UIPanel/UI_TipsForPracticePanel.cs +++ b/Assets/Scripts/UI/UIPanel/UI_TipsForPracticePanel.cs @@ -21,8 +21,7 @@ public class UI_TipsForPracticePanel : BasePanel protected override void Awake() { - base.Awake(); - canvasGroup.alpha = 0f; + canvasGroup.alpha = 1f; // 1. ȡļǰ׺ var sortedItems = Bootstrap.Instance.ppts .Select(path => new @@ -41,6 +40,7 @@ public class UI_TipsForPracticePanel : BasePanel buttonItem.PPTName_Tog.gameObject.name = item.Name; Debug.Log($"Ѵť: {item.Name} (: {item.Order})"); } + base.Awake(); //pptConfig = JsonManager.LoadData("pptConfig"); if (Bootstrap.Instance.ppts == null || Bootstrap.Instance.ppts.Length == 0) { @@ -50,17 +50,17 @@ public class UI_TipsForPracticePanel : BasePanel } - public override async void ShowMe(int time = 0) + public override void ShowMe(int time = 0) { base.ShowMe(); - string pptBtnName = Left_content.GetChild(0).GetComponent().PPTName_Tog.gameObject.name; - OnClick(pptBtnName); - await ToolManager.CanvasFadeIn(canvasGroup, 0.5f); + //string pptBtnName = Left_content.GetChild(0).GetComponent().PPTName_Tog.gameObject.name; + //OnClick(pptBtnName); + ///await ToolManager.CanvasFadeIn(canvasGroup, 0.5f); } - public override async void HideMe(int time = 0) + public override void HideMe(int time = 0) { base.HideMe(); - await ToolManager.CanvasFadeOut(canvasGroup, 0.5f); + //await ToolManager.CanvasFadeOut(canvasGroup, 0.5f); } protected override async void OnClick(string btnName)