From c85ced89ef884d7473c43b199cc3f63e1a8b31dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=86=A0=E5=B3=B0?= Date: Wed, 22 Jan 2025 18:28:15 +0800 Subject: [PATCH] update space shooter --- .../GameScript/Editor/TextureSchema.cs | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/Assets/YooAsset/Samples~/Space Shooter/GameScript/Editor/TextureSchema.cs b/Assets/YooAsset/Samples~/Space Shooter/GameScript/Editor/TextureSchema.cs index d7944676..63ddccb7 100644 --- a/Assets/YooAsset/Samples~/Space Shooter/GameScript/Editor/TextureSchema.cs +++ b/Assets/YooAsset/Samples~/Space Shooter/GameScript/Editor/TextureSchema.cs @@ -5,6 +5,11 @@ using UnityEngine; using UnityEditor; using YooAsset.Editor; +#if UNITY_2019_4_OR_NEWER +using UnityEditor.UIElements; +using UnityEngine.UIElements; +#endif + [CreateAssetMenu(fileName = "TextureSchema", menuName = "YooAssetArt/Create TextureSchema")] public class TextureSchema : ScannerSchema { @@ -90,7 +95,7 @@ public class TextureSchema : ScannerSchema } // 超大纹理 - if(texture.width > MaxWidth || texture.height > MaxHeight) + if (texture.width > MaxWidth || texture.height > MaxHeight) { errorInfo += " | "; errorInfo += "超大纹理"; @@ -146,4 +151,40 @@ public class TextureSchema : ScannerSchema importer.SaveAndReimport(); Debug.Log($"修复了 : {assetPath}"); } + + /// + /// 创建检视面板对 + /// + public override SchemaInspector CreateInspector() + { +#if UNITY_2019_4_OR_NEWER + var container = new VisualElement(); + + // 图片最大宽度 + var maxWidthField = new IntegerField(); + maxWidthField.label = "图片最大宽度"; + maxWidthField.SetValueWithoutNotify(MaxWidth); + maxWidthField.RegisterValueChangedCallback((evt) => + { + MaxWidth = evt.newValue; + }); + container.Add(maxWidthField); + + // 图片最大高度 + var maxHeightField = new IntegerField(); + maxHeightField.label = "图片最大高度"; + maxHeightField.SetValueWithoutNotify(MaxHeight); + maxHeightField.RegisterValueChangedCallback((evt) => + { + MaxHeight = evt.newValue; + }); + container.Add(maxHeightField); + + SchemaInspector inspector = new SchemaInspector(); + inspector.Containner = container; + return inspector; +#else + return null; +#endif + } } \ No newline at end of file