71 lines
2.4 KiB
C#
71 lines
2.4 KiB
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace Thousandto.DIY
|
|
{
|
|
public class CheckPlayCoundScriptEditor : EditorWindow
|
|
{
|
|
[MenuItem("Ares/CheckPlayCoundScriptEditor")]
|
|
static void Open()
|
|
{
|
|
if (Application.isPlaying)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var win = (CheckPlayCoundScriptEditor)EditorWindow.GetWindow(typeof(CheckPlayCoundScriptEditor));
|
|
win.Show();
|
|
}
|
|
|
|
private string _prefabPath = string.Empty;
|
|
void OnGUI()
|
|
{
|
|
EditorGUILayout.BeginVertical();
|
|
EditorGUILayout.LabelField("选择路径");
|
|
EditorGUILayout.Space();
|
|
EditorGUILayout.LabelField("需要修改层的Prefab路径");
|
|
EditorGUILayout.BeginHorizontal();
|
|
if (GUILayout.Button("浏览", GUILayout.Width(50)))
|
|
{
|
|
_prefabPath = EditorUtility.OpenFolderPanel("Change Layer Prefab Path", _prefabPath, "");
|
|
}
|
|
if (string.IsNullOrEmpty(_prefabPath))
|
|
{
|
|
EditorGUILayout.LabelField("null...");
|
|
}
|
|
else
|
|
{
|
|
EditorGUILayout.LabelField(_prefabPath);
|
|
}
|
|
EditorGUILayout.EndHorizontal();
|
|
EditorGUILayout.EndVertical();
|
|
|
|
if (GUILayout.Button("检查", GUILayout.Width(50)))
|
|
{
|
|
if (string.IsNullOrEmpty(_prefabPath))
|
|
return;
|
|
|
|
if (Directory.Exists(_prefabPath))
|
|
{
|
|
DirectoryInfo direction = new DirectoryInfo(_prefabPath);
|
|
FileInfo[] files = direction.GetFiles("*.prefab", SearchOption.AllDirectories);
|
|
for (int i = 0; i < files.Length; ++i)
|
|
{
|
|
var path = files[i].FullName;
|
|
path = path.Replace('\\', '/');
|
|
path = path.Substring(path.IndexOf("Assets"));
|
|
var go = AssetDatabase.LoadAssetAtPath<GameObject>(path);
|
|
var playSounds = go.GetComponentsInChildren<UIPlaySound>();
|
|
if(playSounds != null && playSounds.Length > 0)
|
|
{
|
|
UnityEngine.Debug.LogError(path);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|