From 5b670c2464a5713ff101afdbdea5bb4c8708145b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=80=9D=E6=B5=B7?= <1464576565@qq.com> Date: Thu, 6 Nov 2025 16:31:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Editor/Inspector/UXUIEditor.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Editor/Inspector/UXUIEditor.cs b/Editor/Inspector/UXUIEditor.cs index ad45c80..9b22564 100644 --- a/Editor/Inspector/UXUIEditor.cs +++ b/Editor/Inspector/UXUIEditor.cs @@ -1,5 +1,6 @@ using System; using System.Reflection; +using TMPro; using TMPro.EditorUtilities; using UnityEditor; using UnityEngine; @@ -59,6 +60,27 @@ internal class UXUIEditor : Editor obj.AddComponent(); } + [MenuItem("GameObject/UI/UXInput Field")] + public static void CreateUXInputField(MenuCommand menuCommand) + { + Type MenuOptionsType = typeof(TMPro.EditorUtilities.TMPro_CreateObjectMenu).Assembly.GetType("TMPro.EditorUtilities.TMPro_CreateObjectMenu"); + InvokeMethod(MenuOptionsType, "AddTextMeshProInputField", new object[] { menuCommand }); + GameObject obj = Selection.activeGameObject; + obj.name = "UXInputField"; + TMP_InputField inputField = obj.GetComponent(); + TextMeshProUGUI oldTextField = inputField.placeholder.GetComponent(); + GameObject placeholderGameObject = inputField.placeholder.gameObject; + float oldFontSize = oldTextField.fontSize; + Color oldColor = oldTextField.color; + string oldText = oldTextField.text; + DestroyImmediate(oldTextField); + TextMeshProUGUI newTextField = placeholderGameObject.AddComponent(); + newTextField.fontSize = oldFontSize; + newTextField.color = oldColor; + newTextField.text = oldText; + inputField.placeholder = newTextField; + } + [MenuItem("GameObject/UI/UXScrollView")] private static void CreateUxRecyclerView() {