Merge branch 'HQB_master' of http://172.16.1.12/taosuqi/CultivationOfBrewing-2 into HQB_master
This commit is contained in:
commit
3bb109c6a5
|
|
@ -1,3 +1,4 @@
|
|||
/UserSettings/EditorUserSettings.asset
|
||||
/UniTask.Addressables.csproj
|
||||
/UniTask.csproj
|
||||
/UniTask.DOTween.csproj
|
||||
|
|
|
|||
|
|
@ -242,13 +242,17 @@ PrefabInstance:
|
|||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 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}
|
||||
propertyPath: m_Name
|
||||
value: "\u9AD8\u7CB1"
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 919132149155446097, guid: 51c3521496de1854697d5682cc43afe5, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 51c3521496de1854697d5682cc43afe5, type: 3}
|
||||
|
|
@ -313,13 +317,17 @@ PrefabInstance:
|
|||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 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}
|
||||
propertyPath: m_Name
|
||||
value: "\u9AD8\u7CB1"
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 919132149155446097, guid: 0fc9aae39f3b8fd45959b9f2e382a854, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 0fc9aae39f3b8fd45959b9f2e382a854, type: 3}
|
||||
|
|
|
|||
|
|
@ -685,6 +685,7 @@ GameObject:
|
|||
m_Component:
|
||||
- component: {fileID: 496968027908146854}
|
||||
- component: {fileID: 4042481884953316685}
|
||||
- component: {fileID: 4815313765920862536}
|
||||
m_Layer: 5
|
||||
m_Name: UI_PPTForPracticePanel
|
||||
m_TagString: Untagged
|
||||
|
|
@ -733,6 +734,18 @@ MonoBehaviour:
|
|||
canvasGroup: {fileID: 2747193240799827809}
|
||||
pptFolderName:
|
||||
UI_SelectDevice: {fileID: 1751634905210954150, guid: 7a344e5bc4e2a7a46bcb6cd179226da8, type: 3}
|
||||
--- !u!114 &4815313765920862536
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6017930034823240235}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: cc7c87b8ab572f34fb8f1f3a831ce782, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &6034407815697293954
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
|||
|
|
@ -12,39 +12,47 @@ using Unity.VisualScripting;
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public static class LoadPPTTest
|
||||
/// <summary>
|
||||
/// PPT管理类
|
||||
/// </summary>
|
||||
public class PPTManager : MonoBehaviour
|
||||
{
|
||||
|
||||
public static PPTManager Instance;
|
||||
|
||||
/// <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>
|
||||
/// PPT所有路径
|
||||
/// </summary>
|
||||
private static string[] pptsPath = null;
|
||||
private string[] pptsPath = null;
|
||||
/// <summary>
|
||||
/// 加载单个课程所有图片
|
||||
/// </summary>
|
||||
/// <param name="pptName"></param>
|
||||
/// <returns></returns>
|
||||
public static List<Texture2D> LoadPPTItems(string pptName)
|
||||
public List<Texture2D> LoadPPTItems(string pptName)
|
||||
{
|
||||
string pptPath = GetPPTPathByName(pptName);
|
||||
return GetTexture2DsByName(pptName, pptPath);
|
||||
//target.StartCoroutine(LoadAllPPTFiles(pptPath));
|
||||
}
|
||||
|
||||
protected PPTManager()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
|
||||
public static string[] PPTName()
|
||||
public string[] PPTName()
|
||||
{
|
||||
///切割pptsPath
|
||||
return pptsPath;
|
||||
}
|
||||
|
||||
|
||||
private static List<Texture2D> GetTexture2DsByName(string pptName, string pptPath)
|
||||
private List<Texture2D> GetTexture2DsByName(string pptName, string pptPath)
|
||||
{
|
||||
if (!texturesDic.ContainsKey(pptName))
|
||||
{
|
||||
|
|
@ -66,7 +74,7 @@ public static class LoadPPTTest
|
|||
/// </summary>
|
||||
/// <param name="pptName">名称</param>
|
||||
/// <returns></returns>
|
||||
private static string GetPPTPathByName(string pptName)
|
||||
private string GetPPTPathByName(string pptName)
|
||||
{
|
||||
foreach (var item in pptsPath)
|
||||
{
|
||||
|
|
@ -80,7 +88,7 @@ public static class LoadPPTTest
|
|||
/// 获取文件夹下所有.pptx文件
|
||||
/// </summary>
|
||||
/// <param name="folderPath"></param>
|
||||
public static void PPTFiles(string folderPath)
|
||||
public void PPTFiles(string folderPath)
|
||||
{
|
||||
string fullPPTFolderPath = Path.Combine(Application.streamingAssetsPath, folderPath);
|
||||
pptsPath = Directory.GetFiles(fullPPTFolderPath, "*.pptx");
|
||||
|
|
@ -113,7 +121,7 @@ public static class LoadPPTTest
|
|||
// Debug.Log("所有PPT加载完成!");
|
||||
//}
|
||||
|
||||
public static List<Texture2D> LoadAllPPTFiles(string folderPath)
|
||||
public List<Texture2D> LoadAllPPTFiles(string folderPath)
|
||||
{
|
||||
List<Texture2D> texture2Ds = new List<Texture2D>();
|
||||
Presentation presentation = new Presentation(folderPath);
|
||||
|
|
@ -145,11 +153,68 @@ public static class LoadPPTTest
|
|||
}
|
||||
// 逐个加载每个PPT文件
|
||||
|
||||
//
|
||||
// 添加异步加载接口
|
||||
public IEnumerator LoadPPTAsync(string pptName, Action<List<Texture2D>> callback)
|
||||
{
|
||||
string pptPath = GetPPTPathByName(pptName);
|
||||
|
||||
if (!texturesDic.ContainsKey(pptName))
|
||||
{
|
||||
// 异步加载所有PPT页面
|
||||
yield return StartCoroutine(LoadAllPPTFilesAsync(pptPath, textures => {
|
||||
texturesDic.Add(pptName, textures);
|
||||
callback?.Invoke(textures);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
callback?.Invoke(texturesDic[pptName]);
|
||||
}
|
||||
}
|
||||
|
||||
// 实现逐页异步加载
|
||||
public IEnumerator LoadAllPPTFilesAsync(string folderPath, Action<List<Texture2D>> callback)
|
||||
{
|
||||
List<Texture2D> texture2Ds = new List<Texture2D>();
|
||||
Presentation presentation = new Presentation(folderPath);
|
||||
|
||||
for (int i = 0; i < presentation.Slides.Count; i++)
|
||||
{
|
||||
ISlide slide = presentation.Slides[i];
|
||||
var bitmap = slide.GetThumbnail(1f, 1f);
|
||||
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
bitmap.Save(ms, ImageFormat.Jpeg);
|
||||
byte[] buff = ms.ToArray();
|
||||
|
||||
Texture2D texture2D = new Texture2D(bitmap.Width, bitmap.Height);
|
||||
texture2D.LoadImage(buff);
|
||||
texture2Ds.Add(texture2D);
|
||||
|
||||
// 每加载完一页就触发单页回调
|
||||
OnSinglePageLoaded?.Invoke(texture2D);
|
||||
|
||||
// 每加载完一页就yield一次,避免长时间阻塞
|
||||
yield return null;
|
||||
}
|
||||
|
||||
// 释放bitmap资源
|
||||
bitmap.Dispose();
|
||||
}
|
||||
|
||||
callback?.Invoke(texture2Ds);
|
||||
}
|
||||
|
||||
// 添加单页加载事件
|
||||
public event Action<Texture2D> OnSinglePageLoaded;
|
||||
|
||||
/// <summary>
|
||||
/// 分割ppt路径名称
|
||||
/// </summary>
|
||||
/// <param name="pptname"></param>
|
||||
public static string PathName(string pptname)
|
||||
public string PathName(string pptname)
|
||||
{
|
||||
if (string.IsNullOrEmpty(pptname))
|
||||
{
|
||||
|
|
@ -166,7 +231,7 @@ public static class LoadPPTTest
|
|||
/// <summary>
|
||||
/// 从文件名中提取开头的数字(如 "1-第一章" -> 返回 1)
|
||||
/// </summary>
|
||||
public static int ExtractLeadingNumber(string fileName)
|
||||
public int ExtractLeadingNumber(string fileName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(fileName)) return 0;
|
||||
// 找到第一个数字序列
|
||||
|
|
@ -132,6 +132,10 @@ public class GameManager : SingletonAutoMono<GameManager>
|
|||
/// </summary>
|
||||
public static MissionMgr MissionMgr { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// PPT管理类
|
||||
/// </summary>
|
||||
public static PPTManager PPTManager { get; private set; }
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -161,6 +165,7 @@ public class GameManager : SingletonAutoMono<GameManager>
|
|||
WorkorderMgr = WorkorderMgr.Instance; //工单管理初始化
|
||||
FaultManager = FaultManager.Instance;
|
||||
MissionMgr = MissionMgr.Instance;
|
||||
PPTManager = PPTManager.Instance;
|
||||
DataMgr.Init();
|
||||
WorkorderMgr.Init();
|
||||
NetMgr.Init(SendGet);
|
||||
|
|
|
|||
|
|
@ -29,16 +29,16 @@ public class UI_PPTForPracticePanel : BasePanel
|
|||
canvasGroup.alpha = 1f;
|
||||
|
||||
pptFolderName = Application.streamingAssetsPath + "/PPT";
|
||||
LoadPPTTest.PPTFiles(pptFolderName);
|
||||
PPTManager.Instance.PPTFiles(pptFolderName);
|
||||
|
||||
string[] ppts = LoadPPTTest.PPTName();
|
||||
string[] ppts = PPTManager.Instance.PPTName();
|
||||
// 1. 提取文件名并解析数字前缀
|
||||
var sortedItems = ppts
|
||||
.Select(path => new
|
||||
{
|
||||
Path = path,
|
||||
Name = LoadPPTTest.PathName(path),
|
||||
Order = LoadPPTTest.ExtractLeadingNumber(LoadPPTTest.PathName(path)) // ÌáÈ¡Êý×Ö
|
||||
Name = PPTManager.Instance.PathName(path),
|
||||
Order = PPTManager.Instance.ExtractLeadingNumber(PPTManager.Instance.PathName(path)) // 提取数字
|
||||
})
|
||||
.OrderBy(item => item.Order) // 按数字排序
|
||||
.ToList();
|
||||
|
|
@ -57,23 +57,31 @@ public class UI_PPTForPracticePanel : BasePanel
|
|||
Debug.LogError("PPT路径数组未初始化或为空");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public override void ShowMe()
|
||||
|
||||
void Start()
|
||||
{
|
||||
// 监听单页加载完成事件
|
||||
PPTManager.Instance.OnSinglePageLoaded += texture => {
|
||||
// 立即显示当前加载的页面
|
||||
DisplaySinglePage(texture);
|
||||
};
|
||||
}
|
||||
|
||||
public override void ShowMe()
|
||||
{
|
||||
base.ShowMe();
|
||||
string pptBtnName = Left_content.GetChild(0).GetComponent<UI_TipsForPracticePanelPPTNameItem>().PPTName_Tog.gameObject.name;
|
||||
OnClick(pptBtnName);
|
||||
//await ToolManager.CanvasFadeIn(canvasGroup, 0.5f);
|
||||
}
|
||||
public override void HideMe()
|
||||
public override void HideMe()
|
||||
{
|
||||
base.HideMe();
|
||||
//await ToolManager.CanvasFadeOut(canvasGroup, 0.5f);
|
||||
}
|
||||
|
||||
protected override void OnClick(string btnName)
|
||||
protected override void OnClick(string btnName)
|
||||
{
|
||||
Debug.Log(btnName);
|
||||
switch (btnName)
|
||||
|
|
@ -134,15 +142,31 @@ public class UI_PPTForPracticePanel : BasePanel
|
|||
default:
|
||||
if (isOn)
|
||||
{
|
||||
List<Texture2D> textures = LoadPPTTest.LoadPPTItems(togglePath);
|
||||
if (textures != null)
|
||||
foreach (Transform child in content)//清理之前的图片
|
||||
{
|
||||
DisplayPPT(textures);
|
||||
DestroyImmediate(child.gameObject);
|
||||
}
|
||||
// 启动协程异步加载PPT
|
||||
StartCoroutine(LoadPPTAsync(togglePath, textures =>
|
||||
{
|
||||
if (textures != null)
|
||||
{
|
||||
DisplayPPT(textures);
|
||||
}
|
||||
}));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 添加异步加载方法
|
||||
private IEnumerator LoadPPTAsync(string pptName, Action<List<Texture2D>> callback)
|
||||
{
|
||||
// 调用PPTManager的异步加载方法
|
||||
yield return PPTManager.Instance.LoadPPTAsync(pptName, callback);
|
||||
}
|
||||
|
||||
|
||||
private void DisplayPPT(List<Texture2D> textures)
|
||||
{
|
||||
foreach (Transform child in content)
|
||||
|
|
@ -159,5 +183,15 @@ public class UI_PPTForPracticePanel : BasePanel
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private void DisplaySinglePage(Texture2D texture)
|
||||
{
|
||||
RawImage rawImage = pptImagePrefab.GetComponent<RawImage>();
|
||||
RawImage image = Instantiate(rawImage, content);
|
||||
image.texture = texture;
|
||||
image.rectTransform.sizeDelta = new Vector2(1608, 940);
|
||||
//foreach (Transform child in content)
|
||||
//{
|
||||
// DestroyImmediate(child.gameObject);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 845629668ba4fc24b8fb0ad514c78605
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d3b8ee9a7c9227245b07357e35e66ab7
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2200eae8244115b4ebd869e60a5619d2
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in New Issue