AssetBundleInspector.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System.IO;
  2. using UnityEditor;
  3. using UnityEngine;
  4. namespace YooAsset.Editor
  5. {
  6. public class AssetBundleInspector
  7. {
  8. [CustomEditor(typeof(AssetBundle))]
  9. internal class AssetBundleEditor : UnityEditor.Editor
  10. {
  11. internal bool pathFoldout = false;
  12. internal bool advancedFoldout = false;
  13. public override void OnInspectorGUI()
  14. {
  15. AssetBundle bundle = target as AssetBundle;
  16. using (new EditorGUI.DisabledScope(true))
  17. {
  18. var leftStyle = new GUIStyle(GUI.skin.GetStyle("Label"));
  19. leftStyle.alignment = TextAnchor.UpperLeft;
  20. GUILayout.Label(new GUIContent("Name: " + bundle.name), leftStyle);
  21. var assetNames = bundle.GetAllAssetNames();
  22. pathFoldout = EditorGUILayout.Foldout(pathFoldout, "Source Asset Paths");
  23. if (pathFoldout)
  24. {
  25. EditorGUI.indentLevel++;
  26. foreach (var asset in assetNames)
  27. EditorGUILayout.LabelField(asset);
  28. EditorGUI.indentLevel--;
  29. }
  30. advancedFoldout = EditorGUILayout.Foldout(advancedFoldout, "Advanced Data");
  31. }
  32. if (advancedFoldout)
  33. {
  34. EditorGUI.indentLevel++;
  35. base.OnInspectorGUI();
  36. EditorGUI.indentLevel--;
  37. }
  38. }
  39. }
  40. }
  41. }