From 7fe83e334255c87088f35f0dedaac51be7c36cbe Mon Sep 17 00:00:00 2001 From: Soviby <936858871@qq.com> Date: Thu, 24 Oct 2024 01:30:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E4=BE=8B=E5=8C=96=E6=89=80=E6=9C=89im?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .psd2uguiExamples/Sample.psd | Bin 8022293 -> 8022333 bytes Assets/Editor/EditorConst.cs | 6 +- Assets/Editor/EditorDefine.cs | 6 +- Assets/Editor/Entity/IEntity.cs | 9 ++- Assets/Editor/Entity/ImageEntity.cs | 37 +++++++++++- Assets/Editor/Entity/TextEntity.cs | 4 +- Assets/Editor/Helper/CommandHelper.cs | 4 +- Assets/Editor/Helper/InitHelper.cs | 6 +- Assets/Editor/Helper/LayoutParser.cs | 4 +- Assets/Editor/Helper/PanelHelper.cs | 6 +- Assets/Editor/Manager/ActorManager.cs | 20 ------- Assets/Editor/Manager/ActorManager.cs.meta | 3 - Assets/Editor/Manager/EntityManager.cs | 54 +++++++++++++++--- Assets/Editor/Manager/GlobalManager.cs | 8 ++- Assets/Editor/Manager/StageManager.cs | 12 +++- .../Editor/ScriptObject/CacheScriptObject.cs | 11 +++- .../ScriptObject/SettingScriptObject.cs | 6 +- Assets/Editor/Windows/PanelCacheWindow.cs | 19 +++++- Assets/{Editor => }/UguiToolkit.Editor.asmdef | 4 +- .../UguiToolkit.Editor.asmdef.meta | 0 20 files changed, 159 insertions(+), 60 deletions(-) delete mode 100644 Assets/Editor/Manager/ActorManager.cs delete mode 100644 Assets/Editor/Manager/ActorManager.cs.meta rename Assets/{Editor => }/UguiToolkit.Editor.asmdef (83%) rename Assets/{Editor => }/UguiToolkit.Editor.asmdef.meta (100%) diff --git a/.psd2uguiExamples/Sample.psd b/.psd2uguiExamples/Sample.psd index 09e7e6b03b3fa115575ddc8e54fe251dee39447e..0b47cbaa6db674e901eb75bddee7df58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cwef#w%`jn9rs#`AhZ|Fq8->G`XJh$=bIvuL}P8vE*iYG8+vwsm9NYH9x&j@kR+{iP20kY-%lU^6=Qex6vnCT z#*+E*p>MXqHkB-3T5JwjtZyeCN@Rb5czU{cY@q3$FV~bB=FR=wnV8_zEKq3ZUB0|s zg{TZisEw$ab^5P#7-YuM@{4^>-l*c)2S3GUGkltvPmS^JnMhA8?R- zQ5fHP{&~~TG6bg+?myZ1N&7)ss@WoMa%xHp)v?8ct5-;Ll45YWtkR3`hzYjO^j_A5nUFF{OLW9 z*fSqQ&;29c5r2^2Aj>qi>&S;XOplz_d!K0q1R4;%ng09619r~wB7bwC3+1ZV`Qq`4bT4# DkR`D0 diff --git a/Assets/Editor/EditorConst.cs b/Assets/Editor/EditorConst.cs index 4d11fc7..e98200e 100644 --- a/Assets/Editor/EditorConst.cs +++ b/Assets/Editor/EditorConst.cs @@ -1,4 +1,5 @@ -namespace UguiToolkit.Editor +#if UNITY_EDITOR +namespace UguiToolkit.Editor { public class EditorConst { @@ -9,4 +10,5 @@ public const string RotScaleInfoToolFilePath = "Packages/com.soviby.unity.ui.ugui-toolkit/.tools/result_rot_scale/main.exe"; } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Assets/Editor/EditorDefine.cs b/Assets/Editor/EditorDefine.cs index e00d6de..8a1139c 100644 --- a/Assets/Editor/EditorDefine.cs +++ b/Assets/Editor/EditorDefine.cs @@ -1,4 +1,5 @@ -using System; +#if UNITY_EDITOR +using System; using System.Collections.Generic; namespace UguiToolkit.Editor @@ -16,4 +17,5 @@ namespace UguiToolkit.Editor public float rot; public float[] scale; } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Assets/Editor/Entity/IEntity.cs b/Assets/Editor/Entity/IEntity.cs index 653218d..99c07e5 100644 --- a/Assets/Editor/Entity/IEntity.cs +++ b/Assets/Editor/Entity/IEntity.cs @@ -1,4 +1,4 @@ -using System.Collections; +#if UNITY_EDITOR using Unity.Mathematics; using UnityEngine; @@ -19,6 +19,8 @@ namespace UguiToolkit.Editor private float2 scale; private bool needFillTransform; + protected T2 ElementInfo => m_elementInfo; + public void ApplyTransform(Transform transform) { if (needFillTransform) @@ -27,7 +29,7 @@ namespace UguiToolkit.Editor transform.localScale = new Vector3(scale.x, scale.y, 0); } var position = m_elementInfo.Position; - transform.position = new Vector3(position.x, position.y, 0); + transform.localPosition = new Vector3(position.x, position.y, 0); } // 查找时调用 @@ -55,4 +57,5 @@ namespace UguiToolkit.Editor protected virtual void OnApplyData(T1 ui, T2 elementInfo) { } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Assets/Editor/Entity/ImageEntity.cs b/Assets/Editor/Entity/ImageEntity.cs index feb60d9..6db922c 100644 --- a/Assets/Editor/Entity/ImageEntity.cs +++ b/Assets/Editor/Entity/ImageEntity.cs @@ -1,13 +1,46 @@ -using System.Collections; -using System.Collections.Generic; +#if UNITY_EDITOR using UguiToolkit.Editor; +using UnityEditor; using UnityEngine; using UnityEngine.UI; public class ImageEntity : BaseEntity { + private Image m_previewImage; + protected override void OnApplyData(Image ui, LayoutInfo.ImageInfo elementInfo) { } + + public void InitPreviewImage() { + if (ElementInfo == null) return; + + if (!TryGetComponent(out m_previewImage)) + { + m_previewImage = gameObject.AddComponent(); + } + + LoadImageFromFile(ElementInfo.imgPath); + ApplyTransform(transform); + } + + void LoadImageFromFile(string path) + { + if (System.IO.File.Exists(path)) + { + byte[] fileData = System.IO.File.ReadAllBytes(path); + Texture2D texture = new Texture2D(2, 2); + texture.LoadImage(fileData); // ͼƬݵTexture2D + + Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f)); + m_previewImage.sprite = sprite; + m_previewImage.SetNativeSize(); + } + else + { + Debug.LogError("File not found at path: " + path); + } + } } +#endif \ No newline at end of file diff --git a/Assets/Editor/Entity/TextEntity.cs b/Assets/Editor/Entity/TextEntity.cs index db06fee..d4dfd2b 100644 --- a/Assets/Editor/Entity/TextEntity.cs +++ b/Assets/Editor/Entity/TextEntity.cs @@ -1,3 +1,4 @@ +#if UNITY_EDITOR using System.Collections; using System.Collections.Generic; using UguiToolkit.Editor; @@ -12,4 +13,5 @@ public class TextEntity : BaseEntity ui.fontSize = (int)elementInfo.size; ui.color = elementInfo.color; } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Assets/Editor/Helper/CommandHelper.cs b/Assets/Editor/Helper/CommandHelper.cs index 585733a..714085e 100644 --- a/Assets/Editor/Helper/CommandHelper.cs +++ b/Assets/Editor/Helper/CommandHelper.cs @@ -1,4 +1,5 @@  +#if UNITY_EDITOR using System.Collections.Generic; using UnityEngine; using System.IO; @@ -52,4 +53,5 @@ namespace UguiToolkit.Editor Debug.Log("cmd error : " + error); } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Assets/Editor/Helper/InitHelper.cs b/Assets/Editor/Helper/InitHelper.cs index e433c55..cc6cbe5 100644 --- a/Assets/Editor/Helper/InitHelper.cs +++ b/Assets/Editor/Helper/InitHelper.cs @@ -1,4 +1,5 @@ -using UnityEngine; +#if UNITY_EDITOR +using UnityEngine; using UnityEditor; using System.IO; namespace UguiToolkit.Editor @@ -46,4 +47,5 @@ namespace UguiToolkit.Editor G.cache = cacheScriptObject; } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Assets/Editor/Helper/LayoutParser.cs b/Assets/Editor/Helper/LayoutParser.cs index 81e59b4..bb110d1 100644 --- a/Assets/Editor/Helper/LayoutParser.cs +++ b/Assets/Editor/Helper/LayoutParser.cs @@ -1,4 +1,4 @@ - +#if UNITY_EDITOR using System.Collections.Generic; using System; using Newtonsoft.Json; @@ -113,3 +113,5 @@ namespace UguiToolkit.Editor public string font; } } + +#endif \ No newline at end of file diff --git a/Assets/Editor/Helper/PanelHelper.cs b/Assets/Editor/Helper/PanelHelper.cs index 2180bd6..6682921 100644 --- a/Assets/Editor/Helper/PanelHelper.cs +++ b/Assets/Editor/Helper/PanelHelper.cs @@ -1,4 +1,5 @@ -using UguiToolkit.Editor.Windows; +#if UNITY_EDITOR +using UguiToolkit.Editor.Windows; using UnityEditor; using UnityEditor.SceneManagement; using UnityEngine; @@ -32,4 +33,5 @@ namespace UguiToolkit.Editor PanelCacheWindow.CloseWindow(); } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Assets/Editor/Manager/ActorManager.cs b/Assets/Editor/Manager/ActorManager.cs deleted file mode 100644 index 70d0c60..0000000 --- a/Assets/Editor/Manager/ActorManager.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using UnityEngine; - -namespace UguiToolkit -{ - public class ActorManager : MonoBehaviour, IManager - { - private void Start() - { - // 初始化所有ImageActor - } - - private void Update() - { - // 检测Image是否被选中,并长按2秒,进入选中状态 - - // 选中状态下,每0.3秒检测 - } - } -} \ No newline at end of file diff --git a/Assets/Editor/Manager/ActorManager.cs.meta b/Assets/Editor/Manager/ActorManager.cs.meta deleted file mode 100644 index 902ec4a..0000000 --- a/Assets/Editor/Manager/ActorManager.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: c0bceef231ae47849a692ff9fb726646 -timeCreated: 1719934421 \ No newline at end of file diff --git a/Assets/Editor/Manager/EntityManager.cs b/Assets/Editor/Manager/EntityManager.cs index afeb7de..22f8808 100644 --- a/Assets/Editor/Manager/EntityManager.cs +++ b/Assets/Editor/Manager/EntityManager.cs @@ -1,10 +1,46 @@ -//using System; -//using UnityEngine; +#if UNITY_EDITOR +using UnityEngine; -//namespace UguiToolkit -//{ -// public class EntityManager : MonoBehaviour, IManager -// { -// private PanelCache panelCache; -// } -//} \ No newline at end of file +namespace UguiToolkit.Editor +{ + public class EntityManager : MonoBehaviour, IManager + { + private PanelCache m_panelCache; + private Transform entityRoot; + + public void InitAllEntity(PanelCache panelCache) + { + this.m_panelCache = panelCache; + + // 创建所有实例 + CreateAllEntity(); + } + + private void CreateAllEntity() + { + if (this.m_panelCache == null) return; + var go = new GameObject(); + entityRoot = go.transform; + entityRoot.SetParent(transform); + entityRoot.localPosition = Vector3.zero; + entityRoot.localRotation = Quaternion.identity; + entityRoot.localScale = Vector3.one; + + // Image + foreach (var elementInfo in m_panelCache.GetLayoutElementInfos()) + { + go = new GameObject(); + var entity = go.AddComponent(); + entity.transform.SetParent(entityRoot); + entity.transform.SetSiblingIndex(0); + + entity.SetData(elementInfo); + entity.InitPreviewImage(); + } + + // Text + } + + } +} +#endif \ No newline at end of file diff --git a/Assets/Editor/Manager/GlobalManager.cs b/Assets/Editor/Manager/GlobalManager.cs index ed89508..7fa09f8 100644 --- a/Assets/Editor/Manager/GlobalManager.cs +++ b/Assets/Editor/Manager/GlobalManager.cs @@ -1,4 +1,6 @@ -using UguiToolkit.Editor; +#if UNITY_EDITOR + +using UguiToolkit.Editor; using UnityEditor; namespace UguiToolkit @@ -28,4 +30,6 @@ namespace UguiToolkit AssetDatabase.SaveAssetIfDirty(cache); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Assets/Editor/Manager/StageManager.cs b/Assets/Editor/Manager/StageManager.cs index 90af56e..987be43 100644 --- a/Assets/Editor/Manager/StageManager.cs +++ b/Assets/Editor/Manager/StageManager.cs @@ -1,4 +1,5 @@ -using System; +#if UNITY_EDITOR +using System; using UnityEngine; using UnityEditor; using UnityEngine.SceneManagement; @@ -6,7 +7,6 @@ using System.Collections.Generic; namespace UguiToolkit { - [ExecuteAlways] public class StageManager : MonoBehaviour { private Scene m_scene; @@ -35,6 +35,10 @@ namespace UguiToolkit var go = new GameObject(); go.name = "StageManager"; go.transform.parent = prefabContentsRoot.transform; + go.transform.localPosition = Vector3.zero; + go.transform.localRotation= Quaternion.identity; + go.transform.localScale = Vector3.one; + m_instance = go.AddComponent(); m_instance.m_scene = scene; m_instance.m_prefabContentsRoot = prefabContentsRoot; @@ -64,4 +68,6 @@ namespace UguiToolkit public interface IManager { -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Assets/Editor/ScriptObject/CacheScriptObject.cs b/Assets/Editor/ScriptObject/CacheScriptObject.cs index 1f87bce..64b6adb 100644 --- a/Assets/Editor/ScriptObject/CacheScriptObject.cs +++ b/Assets/Editor/ScriptObject/CacheScriptObject.cs @@ -1,3 +1,4 @@ +#if UNITY_EDITOR using System; using System.Collections; using System.Collections.Generic; @@ -8,8 +9,10 @@ using static UguiToolkit.Editor.LayoutInfo; namespace UguiToolkit.Editor { + [Serializable] public class CacheScriptObject : SerializedScriptableObject { + [SerializeField] public Dictionary panelCaches = new(); } @@ -41,10 +44,12 @@ namespace UguiToolkit.Editor // 通过cmd计算获得 图片路径(源图) -> 旋转缩放信息(效果图) + [SerializeField] public Dictionary> rotScaleInfos = new(); + [SerializeField] public LayoutInfo layoutInfo; - public IEnumerator GetLayoutElementInfos() where T : LayoutInfo.ElementInfo + public IEnumerable GetLayoutElementInfos() where T : LayoutInfo.ElementInfo { if (layoutInfo == null) yield break; @@ -72,8 +77,11 @@ namespace UguiToolkit.Editor [Serializable] public class LayoutInfo: IEnumerable { + [SerializeField] private List m_elementInfos; + [SerializeField] private float m_w; + [SerializeField] private float m_h; public float W => m_w; @@ -160,4 +168,5 @@ namespace UguiToolkit.Editor public float2 scale; } } +#endif diff --git a/Assets/Editor/ScriptObject/SettingScriptObject.cs b/Assets/Editor/ScriptObject/SettingScriptObject.cs index d9e2241..813da36 100644 --- a/Assets/Editor/ScriptObject/SettingScriptObject.cs +++ b/Assets/Editor/ScriptObject/SettingScriptObject.cs @@ -1,4 +1,5 @@ -using Sirenix.OdinInspector; +#if UNITY_EDITOR +using Sirenix.OdinInspector; using UnityEngine; namespace UguiToolkit.Editor @@ -8,4 +9,5 @@ namespace UguiToolkit.Editor [LabelText("ui预制体存放的路径"), FolderPath] public string prefabForUIDirPath; } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Assets/Editor/Windows/PanelCacheWindow.cs b/Assets/Editor/Windows/PanelCacheWindow.cs index 8fcf7f3..f761463 100644 --- a/Assets/Editor/Windows/PanelCacheWindow.cs +++ b/Assets/Editor/Windows/PanelCacheWindow.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +#if UNITY_EDITOR +using System.Collections.Generic; using System.IO; using Sirenix.OdinInspector; using Sirenix.OdinInspector.Editor; @@ -41,7 +42,8 @@ namespace UguiToolkit.Editor.Windows GlobalManager.Instance.SaveCache(); var stageManager = UguiToolkit.StageManager.CreateStageManager(m_prefabStage.scene, m_prefabStage.prefabContentsRoot); - var actorManager = stageManager.CreateSubManager(); + var entityManager = stageManager.CreateSubManager(); + entityManager.InitAllEntity(panelCache); CloseWindow(); } @@ -58,6 +60,16 @@ namespace UguiToolkit.Editor.Windows { var jsonData = reader.ReadToEnd(); var layoutInfo = layoutParser.Parser(jsonData); + + // 对img路径进行修正 + foreach (var elementInfo in layoutInfo) + { + var imgInfo = elementInfo as LayoutInfo.ImageInfo; + if (imgInfo != null) + { + imgInfo.imgPath = System.IO.Path.Join(panelCache.TargetImgDirPath, imgInfo.imgPath) + ".png"; + } + } panelCache.layoutInfo = layoutInfo; } @@ -127,4 +139,5 @@ namespace UguiToolkit.Editor.Windows } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Assets/Editor/UguiToolkit.Editor.asmdef b/Assets/UguiToolkit.Editor.asmdef similarity index 83% rename from Assets/Editor/UguiToolkit.Editor.asmdef rename to Assets/UguiToolkit.Editor.asmdef index 41cff7b..f5b968f 100644 --- a/Assets/Editor/UguiToolkit.Editor.asmdef +++ b/Assets/UguiToolkit.Editor.asmdef @@ -5,7 +5,9 @@ "GUID:d8b63aba1907145bea998dd612889d6b" ], "includePlatforms": [ - "Editor" + "Editor", + "WindowsStandalone32", + "WindowsStandalone64" ], "excludePlatforms": [], "allowUnsafeCode": false, diff --git a/Assets/Editor/UguiToolkit.Editor.asmdef.meta b/Assets/UguiToolkit.Editor.asmdef.meta similarity index 100% rename from Assets/Editor/UguiToolkit.Editor.asmdef.meta rename to Assets/UguiToolkit.Editor.asmdef.meta