Files
TaiWan/Assets/Roaming/Editor/SetShowTestTool.cs
2025-10-31 15:20:38 +08:00

54 lines
1.4 KiB
C#

using UnityEngine;
using UnityEditor;
using System.Linq;
using System.Collections.Generic;
using System.Text;
public class SetShowTestTool : EditorWindow
{
[MenuItem("Tools/SetShowTest Tool")]
public static void ShowWindow()
{
EditorWindow.GetWindow(typeof(SetShowTestTool));
}
void OnGUI()
{
GUILayout.Label("SetShowTest Tool", EditorStyles.boldLabel);
if (GUILayout.Button("SetShowTest As True"))
{
SetShowTest(true);
}
if (GUILayout.Button("SetShowTest As False"))
{
SetShowTest(false);
}
}
private void SetShowTest(bool isTest)
{
GameObject[] objs = Selection.gameObjects;
foreach (var obj in objs)
{
if (obj.transform.childCount == 0)
{
ShowBoxCollider sbc = obj.GetComponent<ShowBoxCollider>();
if (sbc != null)
{
sbc.Test = isTest;
}
}
else
{
for (int i = 0; i < obj.transform.childCount; i++)
{
ShowBoxCollider sbc = obj.transform.GetChild(i).GetComponent<ShowBoxCollider>();
if (sbc != null)
{
sbc.Test = isTest;
}
}
}
}
}
}