添加测试用例

This commit is contained in:
Soviby 2024-11-08 00:16:28 +08:00
parent 97f6cc2a3c
commit 653ecc4f29
25 changed files with 24 additions and 6 deletions

View File

@ -874,9 +874,21 @@ function s2t(t) { return stringIDToTypeID(t) }
} }
this.baseFolder.remove(); this.baseFolder.remove();
} }
this.baseFolder.create(); this.baseFolder.create();
// 导出整个psd作为png参考图
saveFile = new File(this.baseFolder.fsName + "/" + "__background__.png");
options = new ExportOptionsSaveForWeb();
options.format = SaveDocumentType.PNG;
options.PNG8 = false;
options.optimized = true;
options.interlaced = false;
document.exportDocument(saveFile, ExportType.SAVEFORWEB, options);
targets = this.allLayers(document); targets = this.allLayers(document);
//snapShotId = Util.takeSnapshot(document); //snapShotId = Util.takeSnapshot(document);
results = []; results = [];
for (k = 0, len = targets.length; k < len; k++) { for (k = 0, len = targets.length; k < len; k++) {
target = targets[k]; target = targets[k];

Binary file not shown.

View File

@ -0,0 +1 @@
{"info":{"version":"0.6.1","canvas":{"image":{"w":930,"h":2048},"size":{"w":930,"h":2048},"base":{"x":465,"y":1024}}},"root":{"type":"Root","name":"Sample","elements":[{"type":"Group","elements":[{"type":"Text","text":"神仙","font":"AdobeHeitiStd-Regular","size":35,"color":"E7E3B1","align":"center","x":605,"y":1406,"w":66,"h":33,"opacity":100,"imageName":"shenxian","name":"shenxian"},{"type":"Text","text":"修仙","font":"AdobeHeitiStd-Regular","size":48,"color":"FFFFFF","align":"center","x":151,"y":859,"w":90,"h":44,"opacity":100,"imageName":"xiuxian","name":"xiuxian"},{"type":"Button","elements":[{"type":"Image","image":"shitou1","x":94,"y":1351,"w":112,"h":121,"opacity":100,"imageName":"shitou1","name":"shitou1"},{"type":"Image","image":"shitou3","x":342,"y":1408,"w":79,"h":80,"opacity":100,"imageName":"shitou3","name":"shitou3"},{"type":"Image","image":"shitou2","x":209,"y":1393,"w":108,"h":100,"opacity":100,"imageName":"shitou2","name":"shitou2"},{"type":"Image","image":"Background_1","x":20,"y":360,"w":878,"h":353,"opacity":100,"imageName":"Background_1","name":"Background_1"}],"pivot":"top","imageName":"buttonWZZT","name":"buttonWZZT"},{"type":"Button","elements":[{"type":"Image","image":"bgJingjie","x":76,"y":834,"w":339,"h":92,"opacity":100,"imageName":"bgJingjie","name":"bgJingjie"},{"type":"Image","image":"person","x":546,"y":1299,"w":181,"h":136,"opacity":100,"imageName":"person","name":"person"},{"type":"Image","image":"person","x":437,"y":761,"w":429,"h":330,"opacity":100,"imageName":"person","name":"person"},{"type":"Image","image":"Background_2","x":20,"y":1139,"w":871,"h":354,"opacity":100,"imageName":"Background_2","name":"Background_2"},{"type":"Image","image":"Background_2","x":28,"y":749,"w":871,"h":354,"opacity":100,"imageName":"Background_2","name":"Background_2"}],"pivot":"top","imageName":"buttonXiuLian","name":"buttonXiuLian"},{"type":"Image","image":"title","x":287,"y":140,"w":363,"h":114,"opacity":100,"pivot":"top","imageName":"title","name":"title"},{"type":"Image","image":"bj_mo_2","x":0,"y":0,"w":930,"h":2048,"opacity":100,"imageName":"bj_mo_2","name":"bj_mo_2"}],"full":"True","stretchxy":"True","imageName":"panel","name":"panel"}]}}

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -10,16 +10,17 @@ namespace UguiToolkit.Editor
{ {
public static class CommandHelper public static class CommandHelper
{ {
public static void CalcRotScale(string srcImgDirPath, string targetImgDirPath, Action<RotScaleJsonData> callback) public static void CalcRotScale(string srcImgDirPath, string targetImgDirPath, float distanceDifference, Action<RotScaleJsonData> callback)
{ {
var rotScaleInfoFilePath = Path.GetFullPath(EditorConst.RotScaleInfoFilePath); var rotScaleInfoFilePath = Path.GetFullPath(EditorConst.RotScaleInfoFilePath);
var rotScaleInfoToolFilePath = Path.GetFullPath(EditorConst.RotScaleInfoToolFilePath); var rotScaleInfoToolFilePath = Path.GetFullPath(EditorConst.RotScaleInfoToolFilePath);
if (File.Exists(rotScaleInfoFilePath)) File.Delete(rotScaleInfoFilePath); if (File.Exists(rotScaleInfoFilePath)) File.Delete(rotScaleInfoFilePath);
_ = RunCmdAsync(string.Format("{0} -src {1} -target {2} -distance_difference 0.06 -output_path {3}", _ = RunCmdAsync(string.Format("{0} -src {1} -target {2} -distance_difference {3} -output_path {4}",
rotScaleInfoToolFilePath, rotScaleInfoToolFilePath,
Path.GetFullPath(srcImgDirPath), Path.GetFullPath(srcImgDirPath),
Path.GetFullPath(targetImgDirPath), Path.GetFullPath(targetImgDirPath),
distanceDifference,
Path.GetFullPath(rotScaleInfoFilePath)), (output, error) => Path.GetFullPath(rotScaleInfoFilePath)), (output, error) =>
{ {
Debug.Log(output); Debug.Log(output);

View File

@ -130,7 +130,8 @@ namespace UguiToolkit.Editor
private void UpdatePanelCache(string srcImgDirPath, string targetImgDirPath) private void UpdatePanelCache(string srcImgDirPath, string targetImgDirPath)
{ {
CacheScriptObject.CalcRotScaleInfos(srcImgDirPath, targetImgDirPath, (rotScaleInfoMap) => float distanceDifference = GlobalManager.Instance.setting.distanceDifference;
CacheScriptObject.CalcRotScaleInfos(srcImgDirPath, targetImgDirPath, distanceDifference,(rotScaleInfoMap) =>
{ {
if (!m_stageManager) return; if (!m_stageManager) return;
// 拷贝数据 // 拷贝数据

View File

@ -46,10 +46,10 @@ namespace UguiToolkit.Editor
} }
} }
public static void CalcRotScaleInfos(string srcImgDirPath, string targetImgDirPath, Action<Dictionary<string, List<RotScaleInfoItem>>> callback) public static void CalcRotScaleInfos(string srcImgDirPath, string targetImgDirPath, float distanceDifference, Action<Dictionary<string, List<RotScaleInfoItem>>> callback)
{ {
// 执行cmd // 执行cmd
CommandHelper.CalcRotScale(srcImgDirPath, targetImgDirPath, (jsonData) => CommandHelper.CalcRotScale(srcImgDirPath, targetImgDirPath, distanceDifference,(jsonData) =>
{ {
if (jsonData == null || jsonData.data == null) return; if (jsonData == null || jsonData.data == null) return;
Dictionary<string, List<RotScaleInfoItem>> rotScaleInfos = new(); Dictionary<string, List<RotScaleInfoItem>> rotScaleInfos = new();

View File

@ -8,6 +8,8 @@ namespace UguiToolkit.Editor
{ {
[LabelText("ui预制体存放的路径"), FolderPath] [LabelText("ui预制体存放的路径"), FolderPath]
public string prefabForUIDirPath; public string prefabForUIDirPath;
public float distanceDifference = 0.2f;
} }
} }
#endif #endif

View File

@ -35,7 +35,8 @@ namespace UguiToolkit.Editor.Windows
if (m_panelCache == null) if (m_panelCache == null)
{ {
var targetImgDirPath = PanelCache.GetTargetImgDirPath(m_layoutInfoFilePath); var targetImgDirPath = PanelCache.GetTargetImgDirPath(m_layoutInfoFilePath);
CacheScriptObject.CalcRotScaleInfos(m_srcImgDirPath, targetImgDirPath, (rotScaleInfos) => float distanceDifference = GlobalManager.Instance.setting.distanceDifference;
CacheScriptObject.CalcRotScaleInfos(m_srcImgDirPath, targetImgDirPath, distanceDifference, (rotScaleInfos) =>
{ {
if (!stageManager) return; if (!stageManager) return;