一个通过反射的方式检查选定目录的预设是否丢资源的工具,可以检查MeshRender、SkineMesh的材质和动画
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System;
using System.IO;
using System.Runtime.InteropServices;
namespace CandyTools
{
/// <summary>
/// Skinned mesh和meshRender材质引用检查工具
/// </summary>
public class ReferenceFounder : EditorWindow
{
public ReferenceFounder () => Init();
private void Init ()
{
titleContent = new GUIContent( "Missing Reference Founder" );
_pathList = new List<string>(1);
_pathList.Add( string.Empty );
_pathCount = _pathList.Count;
maxSize = new Vector2( 500, 700 );
minSize = new Vector2( 500, 700 );
}
#region GUI
private void OnFocus ()
{
maximized = true;
}
private void OnGUI ()
{
DrawTitle();
DrawPathFields();
DrawCheckButton();
}
#endregion
#region draw
private void DrawPathFields ()
{
GUILayout.BeginVertical();
var cnt = _pathList.Count;
for (int i = 0; i < cnt; i++)
{
GUILayout.BeginHorizontal();
GUILayout.TextField( _pathList[i] ,_textFiedOption);
if (GUILayout.Button( "选择" ))
{
//重写一遍,跨调用效果不好,不如用自带的
var folder = EditorUtility.OpenFolderPanel( "选择文件夹",Application.dataPath,"");
//返回来的绝对路径要手动处理一下,蛋疼
_pathList[i] = SubPath(folder);
}
GUILayout.EndHorizontal();
}
GUILayout.EndVertical();
}
private void DrawCheckButton ()
{
GUILayout.Space( 20 );
GUILayout.BeginVertical();
GUILayout.BeginHorizontal();
if (GUILayout.Button( "-" ))
{
if (_pathList.Count <= 1)
ret