解析layout.txt
This commit is contained in:
parent
40a3afb50b
commit
743745b839
@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Unity.Mathematics;
|
|
||||||
|
|
||||||
namespace UguiToolkit.Editor
|
namespace UguiToolkit.Editor
|
||||||
{
|
{
|
||||||
@ -17,4 +16,42 @@ namespace UguiToolkit.Editor
|
|||||||
public float rot;
|
public float rot;
|
||||||
public float[] scale;
|
public float[] scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class LayoutJsonData
|
||||||
|
{
|
||||||
|
public LayoutInfoJsonData info;
|
||||||
|
public LayoutElementJsonData root;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class LayoutInfoJsonData
|
||||||
|
{
|
||||||
|
public string version;
|
||||||
|
public CanvasInfoJsonData canvas;
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class CanvasInfoJsonData
|
||||||
|
{
|
||||||
|
public CanvasSizeJsonData size;
|
||||||
|
[Serializable]
|
||||||
|
public struct CanvasSizeJsonData
|
||||||
|
{
|
||||||
|
public float w;
|
||||||
|
public float h;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class LayoutElementJsonData
|
||||||
|
{
|
||||||
|
public string type;
|
||||||
|
public string name;
|
||||||
|
public float x;
|
||||||
|
public float y;
|
||||||
|
public float w;
|
||||||
|
public float h;
|
||||||
|
public List<LayoutElementJsonData> element;
|
||||||
|
}
|
||||||
}
|
}
|
@ -8,7 +8,7 @@ namespace UguiToolkit.Editor
|
|||||||
{
|
{
|
||||||
public static class CommandHelper
|
public static class CommandHelper
|
||||||
{
|
{
|
||||||
public static RotScaleJsonData CalcRotScale(in string srcImgDirPath, in string targetImgDirPath, Dictionary<string, List<rotScaleInfoItem>> rotScaleInfos)
|
public static RotScaleJsonData CalcRotScale(in string srcImgDirPath, in string targetImgDirPath, Dictionary<string, List<RotScaleInfoItem>> rotScaleInfos)
|
||||||
{
|
{
|
||||||
var rotScaleInfoFilePath = Path.GetFullPath(EditorConst.RotScaleInfoFilePath);
|
var rotScaleInfoFilePath = Path.GetFullPath(EditorConst.RotScaleInfoFilePath);
|
||||||
var rotScaleInfoToolFilePath = Path.GetFullPath(EditorConst.RotScaleInfoToolFilePath);
|
var rotScaleInfoToolFilePath = Path.GetFullPath(EditorConst.RotScaleInfoToolFilePath);
|
||||||
|
@ -35,14 +35,54 @@ namespace UguiToolkit.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 图片路径 -> 旋转缩放信息
|
// 通过读取layout.txt 获得 position 图片路径(源图) -> Transform信息(效果图)
|
||||||
public Dictionary<string, List<rotScaleInfoItem>> rotScaleInfos = new();
|
public Dictionary<string, List<TargetImageTransformInfo>> targetImageTransformInfos = new();
|
||||||
|
|
||||||
|
// 通过cmd计算获得 图片路径(源图) -> 旋转缩放信息(效果图)
|
||||||
|
public Dictionary<string, List<RotScaleInfoItem>> rotScaleInfos = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public struct rotScaleInfoItem
|
public class LayoutInfo
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class ElementInfo
|
||||||
|
{
|
||||||
|
public float x;
|
||||||
|
public float y;
|
||||||
|
public float w;
|
||||||
|
public float h;
|
||||||
|
|
||||||
|
|
||||||
|
public float3 position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ImageInfo : ElementInfo
|
||||||
{
|
{
|
||||||
public string imgPath;
|
public string imgPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TextInfo : ElementInfo
|
||||||
|
{
|
||||||
|
public string text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public struct TargetImageTransformInfo
|
||||||
|
{
|
||||||
|
public float3 position;
|
||||||
|
public RotScaleInfoItem rotScaleInfo;
|
||||||
|
|
||||||
|
public string ImgPath => rotScaleInfo.imgPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public struct RotScaleInfoItem
|
||||||
|
{
|
||||||
|
public string imgPath; //(效果图)
|
||||||
public float rotiation;
|
public float rotiation;
|
||||||
public float2 scale;
|
public float2 scale;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ namespace UguiToolkit.Editor.Windows
|
|||||||
var rotScaleInfos = panelCache.rotScaleInfos;
|
var rotScaleInfos = panelCache.rotScaleInfos;
|
||||||
foreach (var kv in jsonData.data)
|
foreach (var kv in jsonData.data)
|
||||||
{
|
{
|
||||||
List<rotScaleInfoItem> rotScaleItemList = new();
|
List<RotScaleInfoItem> rotScaleItemList = new();
|
||||||
rotScaleInfos[kv.Key] = rotScaleItemList;
|
rotScaleInfos[kv.Key] = rotScaleItemList;
|
||||||
foreach (var jsonItemData in kv.Value)
|
foreach (var jsonItemData in kv.Value)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user