修改ppt加载(点一个加载一个)
This commit is contained in:
parent
0631c29109
commit
20855f01c0
|
@ -64,7 +64,7 @@ MonoBehaviour:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
m_Material: {fileID: 0}
|
m_Material: {fileID: 0}
|
||||||
m_Color: {r: 1, g: 1, b: 1, a: 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_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||||
m_Maskable: 1
|
m_Maskable: 1
|
||||||
m_OnCullStateChanged:
|
m_OnCullStateChanged:
|
||||||
|
|
|
@ -19,8 +19,8 @@ public class Bootstrap : SingletonMono<Bootstrap>
|
||||||
eventCenter = new EventCenter();
|
eventCenter = new EventCenter();
|
||||||
scenesManager = new ScenesManager(this);
|
scenesManager = new ScenesManager(this);
|
||||||
pptFolderName = Application.streamingAssetsPath + "/PPT";
|
pptFolderName = Application.streamingAssetsPath + "/PPT";
|
||||||
//LoadPPTTest.PPTFiles(pptFolderName);
|
LoadPPTTest.PPTFiles(pptFolderName);
|
||||||
//ppts = LoadPPTTest.PPTName();
|
ppts = LoadPPTTest.PPTName();
|
||||||
DontDestroyOnLoad(gameObject);
|
DontDestroyOnLoad(gameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,10 +33,9 @@ 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);
|
|
||||||
uiManager.ShowPanel<UI_SelectModePanel>(this, E_UI_Layer.Top, (panel) =>
|
uiManager.ShowPanel<UI_SelectModePanel>(this, E_UI_Layer.Top, (panel) =>
|
||||||
{
|
{
|
||||||
//ppts = LoadPPTTest.PPTName();
|
|
||||||
Debug.Log("UI_SelectModePanel");
|
Debug.Log("UI_SelectModePanel");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -80,44 +80,38 @@ public static class LoadPPTTest
|
||||||
/// 获取文件夹下所有.pptx文件
|
/// 获取文件夹下所有.pptx文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="folderPath"></param>
|
/// <param name="folderPath"></param>
|
||||||
public static async void PPTFiles(string folderPath)
|
public static void PPTFiles(string folderPath)
|
||||||
{
|
{
|
||||||
string fullPPTFolderPath = Path.Combine(Application.streamingAssetsPath, folderPath);
|
string fullPPTFolderPath = Path.Combine(Application.streamingAssetsPath, folderPath);
|
||||||
pptsPath = Directory.GetFiles(fullPPTFolderPath, "*.pptx");
|
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)
|
//public static async UniTask LoadAllPPTFiles(string pptName, string folderPath)
|
||||||
{
|
//{
|
||||||
List<Texture2D> texture2Ds = new List<Texture2D>();
|
// List<Texture2D> texture2Ds = new List<Texture2D>();
|
||||||
Presentation presentation = new Presentation(folderPath);
|
// Presentation presentation = new Presentation(folderPath);
|
||||||
// 遍历文档(只做示例使用自己根据需求拓展)
|
// // 遍历文档(只做示例使用自己根据需求拓展)
|
||||||
for (int i = 0; i < presentation.Slides.Count; i++)
|
// for (int i = 0; i < presentation.Slides.Count; i++)
|
||||||
{
|
// {
|
||||||
await UniTask.Yield();
|
// 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数组
|
||||||
using (MemoryStream ms = new MemoryStream())
|
// using (MemoryStream ms = new MemoryStream())
|
||||||
{
|
// {
|
||||||
bitmap.Save(ms, ImageFormat.Jpeg);
|
// bitmap.Save(ms, ImageFormat.Jpeg);
|
||||||
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);
|
||||||
Texture2D texture2D = new Texture2D(2, 2);
|
// Texture2D texture2D = new Texture2D(2, 2);
|
||||||
texture2D.LoadImage(buff);
|
// texture2D.LoadImage(buff);
|
||||||
texture2Ds.Add(texture2D);
|
// texture2Ds.Add(texture2D);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
texturesDic.Add(pptName, texture2Ds);
|
// texturesDic.Add(pptName, texture2Ds);
|
||||||
Debug.Log("所有PPT加载完成!");
|
// Debug.Log("所有PPT加载完成!");
|
||||||
}
|
//}
|
||||||
|
|
||||||
public static List<Texture2D> LoadAllPPTFiles(string folderPath)
|
public static List<Texture2D> LoadAllPPTFiles(string folderPath)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,8 +21,7 @@ public class UI_TipsForPracticePanel : BasePanel
|
||||||
|
|
||||||
protected override void Awake()
|
protected override void Awake()
|
||||||
{
|
{
|
||||||
base.Awake();
|
canvasGroup.alpha = 1f;
|
||||||
canvasGroup.alpha = 0f;
|
|
||||||
// 1. 提取文件名并解析数字前缀
|
// 1. 提取文件名并解析数字前缀
|
||||||
var sortedItems = Bootstrap.Instance.ppts
|
var sortedItems = Bootstrap.Instance.ppts
|
||||||
.Select(path => new
|
.Select(path => new
|
||||||
|
@ -41,6 +40,7 @@ public class UI_TipsForPracticePanel : BasePanel
|
||||||
buttonItem.PPTName_Tog.gameObject.name = item.Name;
|
buttonItem.PPTName_Tog.gameObject.name = item.Name;
|
||||||
Debug.Log($"已创建按钮: {item.Name} (排序键: {item.Order})");
|
Debug.Log($"已创建按钮: {item.Name} (排序键: {item.Order})");
|
||||||
}
|
}
|
||||||
|
base.Awake();
|
||||||
//pptConfig = JsonManager.LoadData<PPTConfig>("pptConfig");
|
//pptConfig = JsonManager.LoadData<PPTConfig>("pptConfig");
|
||||||
if (Bootstrap.Instance.ppts == null || Bootstrap.Instance.ppts.Length == 0)
|
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();
|
base.ShowMe();
|
||||||
string pptBtnName = Left_content.GetChild(0).GetComponent<UI_TipsForPracticePanelPPTNameItem>().PPTName_Tog.gameObject.name;
|
//string pptBtnName = Left_content.GetChild(0).GetComponent<UI_TipsForPracticePanelPPTNameItem>().PPTName_Tog.gameObject.name;
|
||||||
OnClick(pptBtnName);
|
//OnClick(pptBtnName);
|
||||||
await ToolManager.CanvasFadeIn(canvasGroup, 0.5f);
|
///await ToolManager.CanvasFadeIn(canvasGroup, 0.5f);
|
||||||
}
|
}
|
||||||
public override async void HideMe(int time = 0)
|
public override void HideMe(int time = 0)
|
||||||
{
|
{
|
||||||
base.HideMe();
|
base.HideMe();
|
||||||
await ToolManager.CanvasFadeOut(canvasGroup, 0.5f);
|
//await ToolManager.CanvasFadeOut(canvasGroup, 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async void OnClick(string btnName)
|
protected override async void OnClick(string btnName)
|
||||||
|
|
Loading…
Reference in New Issue