FM/Assets/Scripts/Editor/KeyboardEditor.cs

43 lines
1.3 KiB
C#
Raw Normal View History

2025-06-04 22:49:37 +08:00
using HK.Keyboard;
using TMPro;
using UnityEditor;
using UnityEngine;
namespace HK.Editor
{
2025-07-10 23:16:27 +08:00
public class KeyboardEditor : UnityEditor.Editor
2025-06-04 22:49:37 +08:00
{
2025-07-10 23:16:27 +08:00
[MenuItem("GameObject/ZTool/Keyboard/ChangeName")]
2025-06-04 22:49:37 +08:00
public static void ChangeAll()
{
GameObject sele = Selection.activeGameObject;
for (var i = 0; i < sele.transform.childCount; i++)
{
var row = sele.transform.GetChild(i);
if (!row.gameObject.activeSelf)
{
continue;
}
for (var i1 = 0; i1 < row.childCount; i1++)
{
var transform = row.GetChild(i1);
if (!transform.gameObject.activeSelf)
{
continue;
}
var keyBind = transform.GetComponent<KeyBind>();
keyBind.keyName = transform.name;
if (!keyBind.isPic)
{
transform.GetChild(0).GetComponent<TMP_Text>().text = transform.name;
}
else
{
transform.GetChild(0).GetComponent<TMP_Text>().text = "";
}
}
}
}
}
}