初版
8
.PhotoshopScript/JSZXPsd2Unity.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b9fb3fa7ca06e2642a3bf907705706f9
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
1623
.PhotoshopScript/JSZXPsd2Unity/PSD导出Unity.js
Normal file
7
.PhotoshopScript/JSZXPsd2Unity/PSD导出Unity.js.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ed511f3a351ac1840a9e64a11644d50b
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
.PhotoshopScript/JSZXPsd2Unity/lib.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4613883d849a29f40a54e49bfb746fd8
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
2
.PhotoshopScript/JSZXPsd2Unity/lib/json2.min.js
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
// 日本語認識用
|
||||||
|
"object"!=typeof JSON&&(JSON={}),function(){"use strict";function f(t){return 10>t?"0"+t:t}function this_value(){return this.valueOf()}function quote(t){return rx_escapable.lastIndex=0,rx_escapable.test(t)?'"'+t.replace(rx_escapable,function(t){var e=meta[t];return"string"==typeof e?e:"\\u"+("0000"+t.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+t+'"'}function str(t,e){var r,n,o,u,f,a=gap,i=e[t];switch(i&&"object"==typeof i&&"function"==typeof i.toJSON&&(i=i.toJSON(t)),"function"==typeof rep&&(i=rep.call(e,t,i)),typeof i){case"string":return quote(i);case"number":return isFinite(i)?i+"":"null";case"boolean":case"null":return i+"";case"object":if(!i)return"null";if(gap+=indent,f=[],"[object Array]"===Object.prototype.toString.apply(i)){for(u=i.length,r=0;u>r;r+=1)f[r]=str(r,i)||"null";return o=0===f.length?"[]":gap?"[\n"+gap+f.join(",\n"+gap)+"\n"+a+"]":"["+f.join(",")+"]",gap=a,o}if(rep&&"object"==typeof rep)for(u=rep.length,r=0;u>r;r+=1)"string"==typeof rep[r]&&(n=rep[r],o=str(n,i),o&&f.push(quote(n)+(gap?": ":":")+o));else for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(o=str(n,i),o&&f.push(quote(n)+(gap?": ":":")+o));return o=0===f.length?"{}":gap?"{\n"+gap+f.join(",\n"+gap)+"\n"+a+"}":"{"+f.join(",")+"}",gap=a,o}}var rx_one=/^[\],:{}\s]*$/,rx_two=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,rx_three=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,rx_four=/(?:^|:|,)(?:\s*\[)+/g,rx_escapable=/[\\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,rx_dangerous=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},Boolean.prototype.toJSON=this_value,Number.prototype.toJSON=this_value,String.prototype.toJSON=this_value);var gap,indent,meta,rep;"function"!=typeof JSON.stringify&&(meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},JSON.stringify=function(t,e,r){var n;if(gap="",indent="","number"==typeof r)for(n=0;r>n;n+=1)indent+=" ";else"string"==typeof r&&(indent=r);if(rep=e,e&&"function"!=typeof e&&("object"!=typeof e||"number"!=typeof e.length))throw Error("JSON.stringify");return str("",{"":t})}),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){function walk(t,e){var r,n,o=t[e];if(o&&"object"==typeof o)for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(n=walk(o,r),void 0!==n?o[r]=n:delete o[r]);return reviver.call(t,e,o)}var j;if(text+="",rx_dangerous.lastIndex=0,rx_dangerous.test(text)&&(text=text.replace(rx_dangerous,function(t){return"\\u"+("0000"+t.charCodeAt(0).toString(16)).slice(-4)})),rx_one.test(text.replace(rx_two,"@").replace(rx_three,"]").replace(rx_four,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}();
|
7
.PhotoshopScript/JSZXPsd2Unity/lib/json2.min.js.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c5aca7c37ed8912408cb936e4b18d10e
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
1
.PhotoshopScript/README.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
拷贝到 <PS安装目录>\Presets\Scripts\Baum2
|
7
.PhotoshopScript/README.txt.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7aa15847f0dfaf54f9401dc0a307d6ab
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
.psd2uguiExamples/FZYASHJW_ZHUN.TTF
Normal file
BIN
.psd2uguiExamples/Sample.psd
Normal file
1
.psd2uguiExamples/readme.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
用这个psd试试整个流程吧
|
BIN
.tools/result_rot_scale/image/test-1.jpg
Normal file
After Width: | Height: | Size: 850 KiB |
BIN
.tools/result_rot_scale/image/test-10.jpg
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
.tools/result_rot_scale/image/test-20.jpg
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
.tools/result_rot_scale/image/test-30.jpg
Normal file
After Width: | Height: | Size: 265 KiB |
BIN
.tools/result_rot_scale/image_2/test-11.jpg
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
.tools/result_rot_scale/image_2/test-2.jpg
Normal file
After Width: | Height: | Size: 86 KiB |
BIN
.tools/result_rot_scale/image_2/test-21.jpg
Normal file
After Width: | Height: | Size: 878 KiB |
BIN
.tools/result_rot_scale/image_2/test-3.jpg
Normal file
After Width: | Height: | Size: 665 KiB |
BIN
.tools/result_rot_scale/image_2/test-31.jpg
Normal file
After Width: | Height: | Size: 92 KiB |
BIN
.tools/result_rot_scale/image_2/test-4.jpg
Normal file
After Width: | Height: | Size: 127 KiB |
BIN
.tools/result_rot_scale/image_2/test-5.jpg
Normal file
After Width: | Height: | Size: 665 KiB |
BIN
.tools/result_rot_scale/main.exe
Normal file
3
.tools/result_rot_scale/start.bat
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
call main.exe -src image -target image_2 -distance_difference 0.06
|
||||||
|
|
||||||
|
pause
|
8
Assets.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 57cc2dd092a664e4fbd95da444355a2e
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/Editor.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4937e0a4826e0834d9fe00bb4cf2ee64
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
12
Assets/Editor/EditorConst.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
namespace UguiToolkit.Editor
|
||||||
|
{
|
||||||
|
public class EditorConst
|
||||||
|
{
|
||||||
|
public const string WorkspaceDirPath = "Assets/Editor/UguiToolkit";
|
||||||
|
public const string SettingFilePath = WorkspaceDirPath + "/setting.asset";
|
||||||
|
public const string CacheFilePath = WorkspaceDirPath + "/cache.asset";
|
||||||
|
public const string RotScaleInfoFilePath = "Temp/result_rot_scale.json";
|
||||||
|
public const string RotScaleInfoToolFilePath = "Packages/com.soviby.unity.ui.ugui-toolkit/.tools/result_rot_scale/main.exe";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
3
Assets/Editor/EditorConst.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f2268976a28f4f9791aa52b904748da8
|
||||||
|
timeCreated: 1718808905
|
20
Assets/Editor/EditorDefine.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Unity.Mathematics;
|
||||||
|
|
||||||
|
namespace UguiToolkit.Editor
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class RotScaleJsonData
|
||||||
|
{
|
||||||
|
public Dictionary<string, List<RotScaleJsonItemData>> data;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public struct RotScaleJsonItemData
|
||||||
|
{
|
||||||
|
public string targetPath;
|
||||||
|
public float rot;
|
||||||
|
public float[] scale;
|
||||||
|
}
|
||||||
|
}
|
3
Assets/Editor/EditorDefine.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5164a8e1a26945d8a70a23c678306ce6
|
||||||
|
timeCreated: 1719241384
|
3
Assets/Editor/Helper.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 578d542dd0864e8eaa73f7ade426fbae
|
||||||
|
timeCreated: 1718725128
|
55
Assets/Editor/Helper/CommandHelper.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using System.IO;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace UguiToolkit.Editor
|
||||||
|
{
|
||||||
|
public static class CommandHelper
|
||||||
|
{
|
||||||
|
public static RotScaleJsonData CalcRotScale(in string srcImgDirPath, in string targetImgDirPath, Dictionary<string, List<rotScaleInfoItem>> rotScaleInfos)
|
||||||
|
{
|
||||||
|
var rotScaleInfoFilePath = Path.GetFullPath(EditorConst.RotScaleInfoFilePath);
|
||||||
|
var rotScaleInfoToolFilePath = Path.GetFullPath(EditorConst.RotScaleInfoToolFilePath);
|
||||||
|
if (File.Exists(rotScaleInfoFilePath)) File.Delete(rotScaleInfoFilePath);
|
||||||
|
|
||||||
|
RunCmd(string.Format("{0} -src {1} -target {2} -distance_difference 0.06 -output_path {3}",
|
||||||
|
rotScaleInfoToolFilePath,
|
||||||
|
Path.GetFullPath(srcImgDirPath),
|
||||||
|
Path.GetFullPath(targetImgDirPath),
|
||||||
|
Path.GetFullPath(rotScaleInfoFilePath)));
|
||||||
|
if (!File.Exists(rotScaleInfoFilePath))
|
||||||
|
{
|
||||||
|
Debug.LogError($"[E] 文件{rotScaleInfoFilePath} 未能正确获得");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (StreamReader reader = File.OpenText(rotScaleInfoFilePath))
|
||||||
|
{
|
||||||
|
var jsonData = reader.ReadToEnd();
|
||||||
|
RotScaleJsonData rotScaleJsonData = JsonConvert.DeserializeObject<RotScaleJsonData>(jsonData);
|
||||||
|
return rotScaleJsonData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行 cmd 命令
|
||||||
|
public static void RunCmd(in string cmd)
|
||||||
|
{
|
||||||
|
var p = new System.Diagnostics.Process();
|
||||||
|
p.StartInfo.FileName = "cmd.exe";
|
||||||
|
p.StartInfo.Arguments = "/c " + cmd; // 使用 /c 参数执行命令并关闭 cmd 窗口
|
||||||
|
p.StartInfo.UseShellExecute = false;
|
||||||
|
p.StartInfo.RedirectStandardOutput = true;
|
||||||
|
p.StartInfo.RedirectStandardError = true;
|
||||||
|
|
||||||
|
p.Start();
|
||||||
|
var output = p.StandardOutput.ReadToEnd();
|
||||||
|
var error = p.StandardError.ReadToEnd();
|
||||||
|
p.WaitForExit();
|
||||||
|
|
||||||
|
Debug.Log("cmd output : " + output);
|
||||||
|
Debug.Log("cmd error : " + error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
Assets/Editor/Helper/CommandHelper.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c5a6dac91d434baab2b66ee97122eaf3
|
||||||
|
timeCreated: 1718813946
|
49
Assets/Editor/Helper/InitHelper.cs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
using System.IO;
|
||||||
|
namespace UguiToolkit.Editor
|
||||||
|
{
|
||||||
|
public static class InitHelper
|
||||||
|
{
|
||||||
|
[InitializeOnLoadMethod]
|
||||||
|
public static void InitToolkit()
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(EditorConst.WorkspaceDirPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(EditorConst.WorkspaceDirPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
var G = GlobalManager.Instance;
|
||||||
|
|
||||||
|
SettingScriptObject settingScriptObject = null;
|
||||||
|
// 查找配置
|
||||||
|
if (!File.Exists(EditorConst.SettingFilePath))
|
||||||
|
{
|
||||||
|
// 生成配置
|
||||||
|
settingScriptObject = SettingScriptObject.CreateInstance<SettingScriptObject>();
|
||||||
|
AssetDatabase.CreateAsset(settingScriptObject, EditorConst.SettingFilePath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
settingScriptObject = AssetDatabase.LoadAssetAtPath<SettingScriptObject>(EditorConst.SettingFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
G.setting = settingScriptObject;
|
||||||
|
Debug.Log("prefabForUIDirPath " + G.setting.prefabForUIDirPath);
|
||||||
|
|
||||||
|
CacheScriptObject cacheScriptObject = null;
|
||||||
|
// 查找配置
|
||||||
|
if (!File.Exists(EditorConst.CacheFilePath))
|
||||||
|
{
|
||||||
|
// 生成配置
|
||||||
|
cacheScriptObject = CacheScriptObject.CreateInstance<CacheScriptObject>();
|
||||||
|
AssetDatabase.CreateAsset(cacheScriptObject, EditorConst.CacheFilePath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cacheScriptObject = AssetDatabase.LoadAssetAtPath<CacheScriptObject>(EditorConst.CacheFilePath);
|
||||||
|
}
|
||||||
|
G.cache = cacheScriptObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
Assets/Editor/Helper/InitHelper.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1b65657d48eb4a7b814ab2e60b28757a
|
||||||
|
timeCreated: 1718725159
|
35
Assets/Editor/Helper/PanelHelper.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using UguiToolkit.Editor.Windows;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEditor.SceneManagement;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace UguiToolkit.Editor
|
||||||
|
{
|
||||||
|
public static class PanelHelper
|
||||||
|
{
|
||||||
|
[InitializeOnLoadMethod]
|
||||||
|
public static void AddListener()
|
||||||
|
{
|
||||||
|
PrefabStage.prefabStageOpened += OnPrefabStageOpened;
|
||||||
|
PrefabStage.prefabStageClosing += OnPrefabStageClosing;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnPrefabStageOpened(PrefabStage stage)
|
||||||
|
{
|
||||||
|
var setting = GlobalManager.Instance.setting;
|
||||||
|
Debug.Log(stage.assetPath);
|
||||||
|
Debug.Log(setting.prefabForUIDirPath);
|
||||||
|
if (!stage.assetPath.StartsWith(setting.prefabForUIDirPath)) return;
|
||||||
|
|
||||||
|
// 打开配置界面
|
||||||
|
PanelCacheWindow.ShowWindow(stage);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnPrefabStageClosing(PrefabStage stage)
|
||||||
|
{
|
||||||
|
// 关闭配置界面
|
||||||
|
PanelCacheWindow.CloseWindow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
Assets/Editor/Helper/PanelHelper.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 431971bf0f7e47b8bb71094641fcf1a6
|
||||||
|
timeCreated: 1718725294
|
3
Assets/Editor/Manager.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: eca2e2404300497883981b0e0ade0aa2
|
||||||
|
timeCreated: 1718808714
|
24
Assets/Editor/Manager/GlobalManager.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using UguiToolkit.Editor;
|
||||||
|
|
||||||
|
namespace UguiToolkit
|
||||||
|
{
|
||||||
|
public class GlobalManager
|
||||||
|
{
|
||||||
|
private static GlobalManager m_instance;
|
||||||
|
public static GlobalManager Instance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (m_instance == null)
|
||||||
|
{
|
||||||
|
m_instance = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SettingScriptObject setting;
|
||||||
|
public CacheScriptObject cache;
|
||||||
|
}
|
||||||
|
}
|
3
Assets/Editor/Manager/GlobalManager.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: db61dea3021343d386672377c5212671
|
||||||
|
timeCreated: 1718808545
|
3
Assets/Editor/ScriptObject.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 19ac86eedc8f471eb19551f616fc3cbe
|
||||||
|
timeCreated: 1718724991
|
50
Assets/Editor/ScriptObject/CacheScriptObject.cs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Unity.Mathematics;
|
||||||
|
using UnityEngine;
|
||||||
|
using Sirenix.OdinInspector;
|
||||||
|
|
||||||
|
namespace UguiToolkit.Editor
|
||||||
|
{
|
||||||
|
public class CacheScriptObject : SerializedScriptableObject
|
||||||
|
{
|
||||||
|
public Dictionary<GameObject, PanelCache> panelCaches = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class PanelCache
|
||||||
|
{
|
||||||
|
[LabelText("源图片文件夹路径"), FolderPath]
|
||||||
|
public string srcImgDirPath;
|
||||||
|
[LabelText("目标图片信息文件(psd导出)"), FolderPath]
|
||||||
|
public string layoutInfoFilePath; // Sample.layout.txt
|
||||||
|
|
||||||
|
[LabelText("目标图片文件夹路径")]
|
||||||
|
public string TargetImgDirPath
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(layoutInfoFilePath)) return "";
|
||||||
|
var dirName = System.IO.Path.GetDirectoryName(layoutInfoFilePath);
|
||||||
|
var fileName = System.IO.Path.GetFileName(layoutInfoFilePath);
|
||||||
|
var split = fileName.Split(".");
|
||||||
|
if (split.Length == 0) return "";
|
||||||
|
|
||||||
|
return System.IO.Path.Join(dirName, split[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 图片路径 -> 旋转缩放信息
|
||||||
|
public Dictionary<string, List<rotScaleInfoItem>> rotScaleInfos = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public struct rotScaleInfoItem
|
||||||
|
{
|
||||||
|
public string imgPath;
|
||||||
|
public float rotiation;
|
||||||
|
public float2 scale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
11
Assets/Editor/ScriptObject/CacheScriptObject.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 08e8e0ec7fe20dc49944597a9fcef9d2
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
11
Assets/Editor/ScriptObject/SettingScriptObject.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using Sirenix.OdinInspector;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace UguiToolkit.Editor
|
||||||
|
{
|
||||||
|
public class SettingScriptObject : ScriptableObject
|
||||||
|
{
|
||||||
|
[LabelText("ui预制体存放的路径"), FolderPath]
|
||||||
|
public string prefabForUIDirPath;
|
||||||
|
}
|
||||||
|
}
|
3
Assets/Editor/ScriptObject/SettingScriptObject.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: da9b1de6f8c64a8da942aed28dcd111d
|
||||||
|
timeCreated: 1718725010
|
19
Assets/Editor/UguiToolkit.Editor.asmdef
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "UguiToolkit.Editor",
|
||||||
|
"rootNamespace": "",
|
||||||
|
"references": [
|
||||||
|
"GUID:d8b63aba1907145bea998dd612889d6b",
|
||||||
|
"GUID:f5bcd4641e14bde4c8ba640a2285abc5"
|
||||||
|
],
|
||||||
|
"includePlatforms": [
|
||||||
|
"Editor"
|
||||||
|
],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
7
Assets/Editor/UguiToolkit.Editor.asmdef.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b2a36b11213ce2548897e799a58bbcbc
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
3
Assets/Editor/Windows.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8f90099ce01c4a319d2d67d4c5c58bcb
|
||||||
|
timeCreated: 1718811517
|
107
Assets/Editor/Windows/PanelCacheWindow.cs
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Sirenix.OdinInspector;
|
||||||
|
using Sirenix.OdinInspector.Editor;
|
||||||
|
using Unity.Mathematics;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEditor.SceneManagement;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
|
namespace UguiToolkit.Editor.Windows
|
||||||
|
{
|
||||||
|
public class PanelCacheWindow : OdinEditorWindow
|
||||||
|
{
|
||||||
|
private static PanelCacheWindow _window;
|
||||||
|
|
||||||
|
|
||||||
|
[LabelText("源图片文件夹路径"), FolderPath, SerializeField]
|
||||||
|
private string m_srcImgDirPath;
|
||||||
|
[LabelText("目标图片信息文件(psd导出)"), Sirenix.OdinInspector.FilePath(Extensions = "layout.txt"), SerializeField]
|
||||||
|
private string m_layoutInfoFilePath;
|
||||||
|
|
||||||
|
private PrefabStage m_prefabStage;
|
||||||
|
private GameObject m_prefab;
|
||||||
|
private bool m_cacheExist;
|
||||||
|
private PanelCache panelCache;
|
||||||
|
|
||||||
|
[Button("开启助手", ButtonSizes.Medium)]
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
panelCache.srcImgDirPath = m_srcImgDirPath;
|
||||||
|
panelCache.layoutInfoFilePath = m_layoutInfoFilePath;
|
||||||
|
if (!m_cacheExist)
|
||||||
|
{
|
||||||
|
panelCache.rotScaleInfos = new();
|
||||||
|
CalcRotScaleInfos();
|
||||||
|
}
|
||||||
|
|
||||||
|
var cache = GlobalManager.Instance.cache;
|
||||||
|
cache.panelCaches[m_prefab] = panelCache;
|
||||||
|
|
||||||
|
UguiToolkit.StageManager.CreateStageManager(m_prefabStage.scene, m_prefabStage.prefabContentsRoot);
|
||||||
|
CloseWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Button("重新计算旋转和缩放信息", ButtonSizes.Medium), ShowIf(nameof(m_cacheExist))]
|
||||||
|
private void CalcRotScaleInfos()
|
||||||
|
{
|
||||||
|
// 执行cmd
|
||||||
|
var jsonData = CommandHelper.CalcRotScale(panelCache.srcImgDirPath, panelCache.TargetImgDirPath, panelCache.rotScaleInfos);
|
||||||
|
if (jsonData == null || jsonData.data == null) return;
|
||||||
|
var rotScaleInfos = panelCache.rotScaleInfos;
|
||||||
|
foreach (var kv in jsonData.data)
|
||||||
|
{
|
||||||
|
List<rotScaleInfoItem> rotScaleItemList = new();
|
||||||
|
rotScaleInfos[kv.Key] = rotScaleItemList;
|
||||||
|
foreach (var jsonItemData in kv.Value)
|
||||||
|
{
|
||||||
|
rotScaleItemList.Add(new ()
|
||||||
|
{
|
||||||
|
imgPath = jsonItemData.targetPath,
|
||||||
|
rotiation = jsonItemData.rot,
|
||||||
|
scale = new float2(jsonItemData.scale[0], jsonItemData.scale[1])
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Init()
|
||||||
|
{
|
||||||
|
var cache = GlobalManager.Instance.cache;
|
||||||
|
if (cache.panelCaches.TryGetValue(m_prefab, out panelCache))
|
||||||
|
{
|
||||||
|
m_srcImgDirPath = panelCache.srcImgDirPath;
|
||||||
|
m_layoutInfoFilePath = panelCache.layoutInfoFilePath;
|
||||||
|
|
||||||
|
m_cacheExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
panelCache = new PanelCache();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PanelCacheWindow ShowWindow(PrefabStage stage)
|
||||||
|
{
|
||||||
|
if (_window) _window.Close();
|
||||||
|
_window = CreateWindow<PanelCacheWindow>();
|
||||||
|
_window.titleContent = new ("请选择信息后开启助手");
|
||||||
|
_window.m_prefabStage = stage;
|
||||||
|
_window.m_prefab = AssetDatabase.LoadAssetAtPath<GameObject>(stage.assetPath);
|
||||||
|
|
||||||
|
_window.Show();
|
||||||
|
_window.Init();
|
||||||
|
|
||||||
|
return _window;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CloseWindow()
|
||||||
|
{
|
||||||
|
if (_window)
|
||||||
|
{
|
||||||
|
_window.Close();
|
||||||
|
_window = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
Assets/Editor/Windows/PanelCacheWindow.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ff70d2b9c2ba4e88bf10b7087a568d07
|
||||||
|
timeCreated: 1718811805
|
8
Assets/Scripts.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 558d96c5ace2fc7408f8fa23ef43414e
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
3
Assets/Scripts/Manager.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d62d1ab93d3c4beaa6f0d6cf680583da
|
||||||
|
timeCreated: 1718725983
|
20
Assets/Scripts/Manager/ImageActorManager.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace UguiToolkit
|
||||||
|
{
|
||||||
|
public class ImageActorManager : MonoBehaviour
|
||||||
|
{
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
// 初始化所有ImageActor
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
// 检测Image是否被选中,并长按2秒,进入选中状态
|
||||||
|
|
||||||
|
// 选中状态下,每0.3秒检测
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
Assets/Scripts/Manager/ImageActorManager.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c0bceef231ae47849a692ff9fb726646
|
||||||
|
timeCreated: 1719934421
|
58
Assets/Scripts/Manager/StageManager.cs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
|
namespace UguiToolkit
|
||||||
|
{
|
||||||
|
[ExecuteAlways]
|
||||||
|
public class StageManager : MonoBehaviour
|
||||||
|
{
|
||||||
|
private Scene m_scene;
|
||||||
|
public Scene Scene => m_scene;
|
||||||
|
private GameObject m_prefabContentsRoot;
|
||||||
|
public GameObject PrefabContentsRoot => m_prefabContentsRoot;
|
||||||
|
|
||||||
|
private static StageManager m_instance;
|
||||||
|
public static StageManager Instance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (!m_instance)
|
||||||
|
{
|
||||||
|
Debug.LogError("[E] stageManager 不存在,请先进入预制体SceneStage场景");
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CreateStageManager(Scene scene, GameObject prefabContentsRoot)
|
||||||
|
{
|
||||||
|
var go = new GameObject();
|
||||||
|
go.name = "StageManager";
|
||||||
|
go.transform.parent = prefabContentsRoot.transform;
|
||||||
|
m_instance = go.AddComponent<StageManager>();
|
||||||
|
m_instance.m_scene = scene;
|
||||||
|
m_instance.m_prefabContentsRoot = prefabContentsRoot;
|
||||||
|
|
||||||
|
go.hideFlags = HideFlags.DontSave;
|
||||||
|
}
|
||||||
|
|
||||||
|
private T CreateSubManager<T>() where T : MonoBehaviour
|
||||||
|
{
|
||||||
|
var go = new GameObject();
|
||||||
|
go.name = typeof(T).Name;
|
||||||
|
go.transform.parent = PrefabContentsRoot.transform;
|
||||||
|
var t = go.AddComponent<T>();
|
||||||
|
|
||||||
|
go.hideFlags = HideFlags.DontSave;
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
CreateSubManager<ImageActorManager>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
Assets/Scripts/Manager/StageManager.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7649968946ba4e1fbf16181d36d339ba
|
||||||
|
timeCreated: 1718726030
|
18
Assets/Scripts/UguiToolkit.asmdef
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"name": "UguiToolkit",
|
||||||
|
"rootNamespace": "",
|
||||||
|
"references": [],
|
||||||
|
"includePlatforms": [
|
||||||
|
"Editor",
|
||||||
|
"WindowsStandalone32",
|
||||||
|
"WindowsStandalone64"
|
||||||
|
],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
7
Assets/Scripts/UguiToolkit.asmdef.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f5bcd4641e14bde4c8ba640a2285abc5
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
10
package.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"name": "com.soviby.unity.ui.ugui-toolkit",
|
||||||
|
"displayName": "UguiToolkit",
|
||||||
|
"description": "Ugui拼接辅助帮手",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"unity": "2022.3",
|
||||||
|
"author": "Soviby",
|
||||||
|
"dependencies": {
|
||||||
|
}
|
||||||
|
}
|
7
package.json.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5260e23a46c07ca4099a65b4a9011199
|
||||||
|
PackageManifestImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|