暂时提交视频导出功能

This commit is contained in:
李浩 2025-05-12 17:26:46 +08:00
parent 778032b3db
commit fb2bddcbae
5 changed files with 84 additions and 1 deletions

View File

@ -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<UITipWindow>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish());
}

View File

@ -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;
/// <summary>

View File

@ -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<ItemData> btns = new List<ItemData>();
@ -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
}
}
}

View File

@ -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;
}

View File

@ -158,6 +158,11 @@
<Action type="Show" value="DanFan_2DCanvas/Connet/BaoGuangGroup" isShow="false"></Action>
<Action type="Show" value="DanFan_2DCanvas/Connet/拍照焦点_红色" isShow="false"></Action>
<Action type="TipWindow" exportVideoPath="GenJingTou.mp4" value="恭喜你完成摄像机拍摄,点击确定,保存摄像机拍摄文件" btns="确定"> </Action>
<Condition type="UIClick" value="UIRoot/PopUI/UITipWindow/Mask/Connnet/BtnContent/确定"></Condition>
<Action type="OperationChange" name="初始化"></Action>
</Action>
</Enter>
@ -876,7 +881,7 @@
<Action type="TipWindow" value="恭喜你完成摄像机拍摄,点击确定,保存摄像机拍摄文件" btns="确定"> </Action>
<Action type="TipWindow" ExportVideoPath="GenJingTou.mp4" value="恭喜你完成摄像机拍摄,点击确定,保存摄像机拍摄文件" btns="确定"> </Action>