diff --git a/Assets/Scripts/Actions/TipWindowAction.cs b/Assets/Scripts/Actions/TipWindowAction.cs index 2c987f51..50d9b156 100644 --- a/Assets/Scripts/Actions/TipWindowAction.cs +++ b/Assets/Scripts/Actions/TipWindowAction.cs @@ -59,6 +59,7 @@ public class TipWindowAction : IAction } } data.audio = datas.ContainsKey("audio") ? datas["audio"] : null; + data.ExportVideoPath = datas.ContainsKey("exportVideoPath") ? datas["exportVideoPath"] : null; UIKit.OpenPanelAsync(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish()); } diff --git a/Assets/Scripts/Tools/ChinarFileController.cs b/Assets/Scripts/Tools/ChinarFileController.cs index 1e6c7dc0..b4bca0ab 100644 --- a/Assets/Scripts/Tools/ChinarFileController.cs +++ b/Assets/Scripts/Tools/ChinarFileController.cs @@ -1,6 +1,10 @@ using UnityEngine; using System.Runtime.InteropServices; using System; +using System.IO; +using UnityEngine.Video; +using DG.Tweening.Plugins.Core.PathCore; +using Path = System.IO.Path; /// diff --git a/Assets/Scripts/UI/UITipWindow.cs b/Assets/Scripts/UI/UITipWindow.cs index e87e9b9f..93f7a6b8 100644 --- a/Assets/Scripts/UI/UITipWindow.cs +++ b/Assets/Scripts/UI/UITipWindow.cs @@ -5,6 +5,9 @@ using System; using System.Collections.Generic; using TMPro; using static OperationController; +using UnityEngine.Video; +using System.IO; +using System.Threading.Tasks; namespace QFramework.Example { @@ -15,6 +18,7 @@ namespace QFramework.Example public string txt; public Action OnClick; } + public string ExportVideoPath; public string txt; public string audio; public List btns = new List(); @@ -73,8 +77,17 @@ namespace QFramework.Example }); loader.LoadAsync(); } + + + + + + transform.SetAsLastSibling(); + + } + protected override void OnShow() { @@ -88,6 +101,61 @@ namespace QFramework.Example protected override void OnClose() { loader.Recycle2Cache(); + + + if (string.IsNullOrEmpty(mData.ExportVideoPath) == false) + { + + string OutPath = ""; + string filePath = ChinarFileController.SaveProject(OutPath); + string sourcePath = Global.videoPath + mData.ExportVideoPath; +#if UNITY_WEBGL && !UNITY_EDITOR + + + + + + +#elif UNITY_STANDALONE_WIN || UNITY_EDITOR + + try + { + // 确保目标目录存在 + string directory = Path.GetDirectoryName(sourcePath); + if (!Directory.Exists(directory)) + { + Directory.CreateDirectory(directory); + } + + // 尝试复制文件(覆盖已存在文件) + File.Copy(sourcePath, filePath, true); + Debug.Log("文件复制成功!"); + } + catch (IOException e) + { + // 处理共享冲突或其他IO异常 + Debug.LogError($"文件复制失败: {e.Message}"); + + // 可选:提供更具体的错误信息 + if (e.Message.Contains("Sharing violation")) + { + Debug.LogError("错误:文件正在被其他程序使用!请关闭相关应用后重试。"); + } + } + catch (System.Exception e) + { + // 处理其他异常 + + Debug.LogError($"发生未知错误: {e.Message}"); + } + + } + else + { + + } +#endif + } } } diff --git a/Assets/Scripts/Xml/XmlParser.cs b/Assets/Scripts/Xml/XmlParser.cs index 62c12cca..e21ffe26 100644 --- a/Assets/Scripts/Xml/XmlParser.cs +++ b/Assets/Scripts/Xml/XmlParser.cs @@ -1007,6 +1007,11 @@ namespace XMLTool { act.args.Add("alpha", alpha.Value); } + XAttribute exportVideoPath = action.Attribute("exportVideoPath"); + if (exportVideoPath != null) + { + act.args.Add("exportVideoPath", exportVideoPath.Value); + } newAction = act; } diff --git a/Data/Xml/03_ChangJingXuNiPaiShe.xml b/Data/Xml/03_ChangJingXuNiPaiShe.xml index fb525a0a..ce8b88e2 100644 --- a/Data/Xml/03_ChangJingXuNiPaiShe.xml +++ b/Data/Xml/03_ChangJingXuNiPaiShe.xml @@ -158,6 +158,11 @@ + + + + + @@ -876,7 +881,7 @@ - +