PPT加载优化

This commit is contained in:
huqibin 2025-05-26 14:11:50 +08:00
parent 5a4930e5a6
commit 1bf24f0b9b
11 changed files with 58 additions and 18 deletions

View File

@ -242,13 +242,17 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z propertyPath: m_LocalEulerAnglesHint.z
value: 0 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -7511558181221131132, guid: 51c3521496de1854697d5682cc43afe5, type: 3}
propertyPath: m_Enabled
value: 0
objectReference: {fileID: 0}
- target: {fileID: 919132149155446097, guid: 51c3521496de1854697d5682cc43afe5, type: 3} - target: {fileID: 919132149155446097, guid: 51c3521496de1854697d5682cc43afe5, type: 3}
propertyPath: m_Name propertyPath: m_Name
value: "\u9AD8\u7CB1" value: "\u9AD8\u7CB1"
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 919132149155446097, guid: 51c3521496de1854697d5682cc43afe5, type: 3} - target: {fileID: 919132149155446097, guid: 51c3521496de1854697d5682cc43afe5, type: 3}
propertyPath: m_IsActive propertyPath: m_IsActive
value: 0 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 51c3521496de1854697d5682cc43afe5, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 51c3521496de1854697d5682cc43afe5, type: 3}
@ -313,13 +317,17 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z propertyPath: m_LocalEulerAnglesHint.z
value: 0 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -7511558181221131132, guid: 0fc9aae39f3b8fd45959b9f2e382a854, type: 3}
propertyPath: m_Enabled
value: 0
objectReference: {fileID: 0}
- target: {fileID: 919132149155446097, guid: 0fc9aae39f3b8fd45959b9f2e382a854, type: 3} - target: {fileID: 919132149155446097, guid: 0fc9aae39f3b8fd45959b9f2e382a854, type: 3}
propertyPath: m_Name propertyPath: m_Name
value: "\u9AD8\u7CB1" value: "\u9AD8\u7CB1"
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 919132149155446097, guid: 0fc9aae39f3b8fd45959b9f2e382a854, type: 3} - target: {fileID: 919132149155446097, guid: 0fc9aae39f3b8fd45959b9f2e382a854, type: 3}
propertyPath: m_IsActive propertyPath: m_IsActive
value: 0 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 0fc9aae39f3b8fd45959b9f2e382a854, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 0fc9aae39f3b8fd45959b9f2e382a854, type: 3}

View File

@ -12,39 +12,45 @@ using Unity.VisualScripting;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
public static class LoadPPTTest /// <summary>
/// PPT管理类
/// </summary>
public class PPTManager : BaseManager<PPTManager>
{ {
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
private static Dictionary<string, List<Texture2D>> texturesDic = new Dictionary<string, List<Texture2D>>(); private Dictionary<string, List<Texture2D>> texturesDic = new Dictionary<string, List<Texture2D>>();
/// <summary> /// <summary>
/// PPT所有路径 /// PPT所有路径
/// </summary> /// </summary>
private static string[] pptsPath = null; private string[] pptsPath = null;
/// <summary> /// <summary>
/// 加载单个课程所有图片 /// 加载单个课程所有图片
/// </summary> /// </summary>
/// <param name="pptName"></param> /// <param name="pptName"></param>
/// <returns></returns> /// <returns></returns>
public static List<Texture2D> LoadPPTItems(string pptName) public List<Texture2D> LoadPPTItems(string pptName)
{ {
string pptPath = GetPPTPathByName(pptName); string pptPath = GetPPTPathByName(pptName);
return GetTexture2DsByName(pptName, pptPath); return GetTexture2DsByName(pptName, pptPath);
//target.StartCoroutine(LoadAllPPTFiles(pptPath)); //target.StartCoroutine(LoadAllPPTFiles(pptPath));
} }
protected PPTManager()
{
}
public static string[] PPTName() public string[] PPTName()
{ {
///切割pptsPath ///切割pptsPath
return pptsPath; return pptsPath;
} }
private static List<Texture2D> GetTexture2DsByName(string pptName, string pptPath) private List<Texture2D> GetTexture2DsByName(string pptName, string pptPath)
{ {
if (!texturesDic.ContainsKey(pptName)) if (!texturesDic.ContainsKey(pptName))
{ {
@ -66,7 +72,7 @@ public static class LoadPPTTest
/// </summary> /// </summary>
/// <param name="pptName">名称</param> /// <param name="pptName">名称</param>
/// <returns></returns> /// <returns></returns>
private static string GetPPTPathByName(string pptName) private string GetPPTPathByName(string pptName)
{ {
foreach (var item in pptsPath) foreach (var item in pptsPath)
{ {
@ -80,7 +86,7 @@ public static class LoadPPTTest
/// 获取文件夹下所有.pptx文件 /// 获取文件夹下所有.pptx文件
/// </summary> /// </summary>
/// <param name="folderPath"></param> /// <param name="folderPath"></param>
public static void PPTFiles(string folderPath) public 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");
@ -113,7 +119,7 @@ public static class LoadPPTTest
// Debug.Log("所有PPT加载完成"); // Debug.Log("所有PPT加载完成");
//} //}
public static List<Texture2D> LoadAllPPTFiles(string folderPath) public List<Texture2D> LoadAllPPTFiles(string folderPath)
{ {
List<Texture2D> texture2Ds = new List<Texture2D>(); List<Texture2D> texture2Ds = new List<Texture2D>();
Presentation presentation = new Presentation(folderPath); Presentation presentation = new Presentation(folderPath);
@ -149,7 +155,7 @@ public static class LoadPPTTest
/// 分割ppt路径名称 /// 分割ppt路径名称
/// </summary> /// </summary>
/// <param name="pptname"></param> /// <param name="pptname"></param>
public static string PathName(string pptname) public string PathName(string pptname)
{ {
if (string.IsNullOrEmpty(pptname)) if (string.IsNullOrEmpty(pptname))
{ {
@ -166,7 +172,7 @@ public static class LoadPPTTest
/// <summary> /// <summary>
/// 从文件名中提取开头的数字(如 "1-第一章" -> 返回 1 /// 从文件名中提取开头的数字(如 "1-第一章" -> 返回 1
/// </summary> /// </summary>
public static int ExtractLeadingNumber(string fileName) public int ExtractLeadingNumber(string fileName)
{ {
if (string.IsNullOrEmpty(fileName)) return 0; if (string.IsNullOrEmpty(fileName)) return 0;
// 找到第一个数字序列 // 找到第一个数字序列

View File

@ -132,6 +132,10 @@ public class GameManager : SingletonAutoMono<GameManager>
/// </summary> /// </summary>
public static MissionMgr MissionMgr { get; private set; } public static MissionMgr MissionMgr { get; private set; }
/// <summary>
/// PPT管理类
/// </summary>
public static PPTManager PPTManager { get; private set; }
#endregion #endregion
/// <summary> /// <summary>
@ -161,6 +165,7 @@ public class GameManager : SingletonAutoMono<GameManager>
WorkorderMgr = WorkorderMgr.Instance; //工单管理初始化 WorkorderMgr = WorkorderMgr.Instance; //工单管理初始化
FaultManager = FaultManager.Instance; FaultManager = FaultManager.Instance;
MissionMgr = MissionMgr.Instance; MissionMgr = MissionMgr.Instance;
PPTManager = PPTManager.Instance;
DataMgr.Init(); DataMgr.Init();
WorkorderMgr.Init(); WorkorderMgr.Init();
NetMgr.Init(SendGet); NetMgr.Init(SendGet);

View File

@ -29,16 +29,16 @@ public class UI_PPTForPracticePanel : BasePanel
canvasGroup.alpha = 1f; canvasGroup.alpha = 1f;
pptFolderName = Application.streamingAssetsPath + "/PPT"; pptFolderName = Application.streamingAssetsPath + "/PPT";
LoadPPTTest.PPTFiles(pptFolderName); GameManager.PPTManager.PPTFiles(pptFolderName);
string[] ppts = LoadPPTTest.PPTName(); string[] ppts = GameManager.PPTManager.PPTName();
// 1. 提取文件名并解析数字前缀 // 1. 提取文件名并解析数字前缀
var sortedItems = ppts var sortedItems = ppts
.Select(path => new .Select(path => new
{ {
Path = path, Path = path,
Name = LoadPPTTest.PathName(path), Name = GameManager.PPTManager.PathName(path),
Order = LoadPPTTest.ExtractLeadingNumber(LoadPPTTest.PathName(path)) // 提取数字 Order = GameManager.PPTManager.ExtractLeadingNumber(GameManager.PPTManager.PathName(path)) // ÌáÈ¡Êý×Ö
}) })
.OrderBy(item => item.Order) // 按数字排序 .OrderBy(item => item.Order) // 按数字排序
.ToList(); .ToList();
@ -134,7 +134,7 @@ public class UI_PPTForPracticePanel : BasePanel
default: default:
if (isOn) if (isOn)
{ {
List<Texture2D> textures = LoadPPTTest.LoadPPTItems(togglePath); List<Texture2D> textures = GameManager.PPTManager.LoadPPTItems(togglePath);
if (textures != null) if (textures != null)
{ {
DisplayPPT(textures); DisplayPPT(textures);

Binary file not shown.

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 845629668ba4fc24b8fb0ad514c78605
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d3b8ee9a7c9227245b07357e35e66ab7
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2200eae8244115b4ebd869e60a5619d2
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: