修改加载PPT逻辑

This commit is contained in:
yanghua 2025-04-08 17:37:58 +08:00
parent ac9acefe98
commit 64b0c04cd5
2 changed files with 4 additions and 4 deletions

View File

@ -31,7 +31,7 @@ public class Bootstrap : SingletonMono<Bootstrap>
{ {
uiManager.ShowPanel<UI_BGPanel>(this, E_UI_Layer.Bot, (panel) => uiManager.ShowPanel<UI_BGPanel>(this, E_UI_Layer.Bot, (panel) =>
{ {
//LoadPPTTest.PPTFiles(pptFolderName); LoadPPTTest.PPTFiles(pptFolderName);
uiManager.ShowPanel<UI_SelectModePanel>(this, E_UI_Layer.Top, (panel) => uiManager.ShowPanel<UI_SelectModePanel>(this, E_UI_Layer.Top, (panel) =>
{ {
ppts = LoadPPTTest.PPTName(); ppts = LoadPPTTest.PPTName();

View File

@ -79,6 +79,7 @@ public static class LoadPPTTest
for (int i = 0; i < pptsPath.Length; i++) for (int i = 0; i < pptsPath.Length; i++)
{ {
string pptName = PathName(pptsPath[i]); string pptName = PathName(pptsPath[i]);
await UniTask.Yield();
await LoadAllPPTFiles(pptName, pptsPath[i]); await LoadAllPPTFiles(pptName, pptsPath[i]);
} }
} }
@ -91,6 +92,7 @@ public static class LoadPPTTest
// 遍历文档(只做示例使用自己根据需求拓展) // 遍历文档(只做示例使用自己根据需求拓展)
for (int i = 0; i < presentation.Slides.Count; i++) for (int i = 0; i < presentation.Slides.Count; i++)
{ {
await UniTask.Yield();
ISlide slide = presentation.Slides[i]; ISlide slide = presentation.Slides[i];
var bitmap = slide.GetThumbnail(1f, 1f); var bitmap = slide.GetThumbnail(1f, 1f);
// 声明内存流将图片转换为内存流再由流转换为byte数组然后用texture2d加载byte数组 // 声明内存流将图片转换为内存流再由流转换为byte数组然后用texture2d加载byte数组
@ -100,9 +102,7 @@ public static class LoadPPTTest
byte[] buff = new byte[ms.Length]; byte[] buff = new byte[ms.Length];
ms.Seek(0, SeekOrigin.Begin); ms.Seek(0, SeekOrigin.Begin);
await ms.ReadAsync(buff, 0, (int)ms.Length); await ms.ReadAsync(buff, 0, (int)ms.Length);
// 注意这个image的命名空间为system.drawing不是unity.ui,这个图片的目的是提供图片的宽高 Texture2D texture2D = new Texture2D(2, 2);
System.Drawing.Image sizeImage = System.Drawing.Image.FromStream(ms);
Texture2D texture2D = new Texture2D(sizeImage.Width, sizeImage.Height);
texture2D.LoadImage(buff); texture2D.LoadImage(buff);
texture2Ds.Add(texture2D); texture2Ds.Add(texture2D);
} }