查看Prefab的依赖文件
查看prefab依赖的所有文件
using UnityEngine; using System.Collections; using UnityEditor; using System.Linq; public class EditorGUIObjectField : EditorWindow { Object selectObj = null; GameObject lastSelectObj = null; Object[] dependOBjs = null; [MenuItem("Test/Select Dependencies")] static void Init() { var window = GetWindow(typeof(EditorGUIObjectField)) as ExportAssetWindow; window.position = new Rect(0, 0, 250, 80); window.Show(); } void OnInspectorUpdate() { Repaint(); } Vector2 scrollPos = Vector2.zero; void OnGUI() { GUILayout.Label(null != Selection.gameObjects && Selection.gameObjects.Length > 0 ?new GUIContent(string.Format("{0} {1}",ObjectNames.GetClassName(Selection.gameObjects[0]),Selection.gameObjects[0].GetInstanceID())):new GUIContent("unkown")); selectObj = EditorGUILayout.ObjectField(selectObj, typeof(GameObject),true) as GameObject; if (selectObj) { if (null != lastSelectObj && lastSelectObj != selectObj) dependOBjs = null; GUILayout.BeginHorizontal(); GUILayout.EndHorizontal(); if (GUILayout.Button("Check Dependencies")) dependOBjs = EditorUtility.CollectDependencies(new Object[] { selectObj }); if (null == dependOBjs || dependOBjs.Length <= 0) return; scrollPos = EditorGUILayout.BeginScrollView(scrollPos); string tmpPath = null; foreach (Object obj in dependOBjs) { if (null == obj) continue; tmpPath = AssetDatabase.GetAssetOrScenePath(obj); EditorGUILayout.BeginHorizontal(); EditorGUILayout.ObjectField(obj, typeof(Object),false); EditorGUILayout.LabelField(string.Format("({0}) {1}", AssetDatabase.AssetPathToGUID(tmpPath),tmpPath)); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); } } }