Framwork/Assets/Scripts/Editor/KeyboardEditor.cs

43 lines
1.3 KiB
C#

using HK.Keyboard;
using TMPro;
using UnityEditor;
using UnityEngine;
namespace HK.Editor
{
public class KeyboardEditor : UnityEditor.Editor
{
[MenuItem("GameObject/ZTool/Keyboard/ChangeName")]
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 = "";
}
}
}
}
}
}