少年修仙传客户端基础资源
dabaoji
2023-11-13 0a23e1b83f8fda8ab9f9e32fe71c26c431faf63a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using UnityEditor;
using UnityEditor.IMGUI.Controls;
using System.Collections.Generic;
using System.IO;
using System;
 
namespace UnityEngine.AssetBundles
{
    class SingleBundleInspector
    {
        public static string currentPath { get; set; }
 
 
        public SingleBundleInspector() { }
 
        private Editor m_Editor = null;
 
        private Rect m_Position;
 
        [SerializeField]
        private Vector2 m_ScrollPosition;
 
        public void SetBundle(AssetBundle bundle, string path = "")
        {
            //static var...
            currentPath = path;
 
            //members
            m_Editor = null;
            if (bundle != null)
                m_Editor = Editor.CreateEditor(bundle);
        }
 
        public void OnGUI(Rect pos)
        {
            if (m_Editor == null)
                return;
 
            m_Position = pos;
 
            DrawBundleData();
        }
 
        private void DrawBundleData()
        {
            GUILayout.BeginArea(m_Position);
            m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition);
            m_Editor.OnInspectorGUI();
            EditorGUILayout.EndScrollView();
            GUILayout.EndArea();
        }
    }
 
    [CustomEditor(typeof(AssetBundle))]
    public class LevelScriptEditor : Editor
    {
        public override void OnInspectorGUI()
        {
            AssetBundle bundle = target as AssetBundle;
 
            using (new EditorGUI.DisabledScope(true))
            {
                var leftStyle = GUI.skin.GetStyle("Label");
                leftStyle.alignment = TextAnchor.UpperLeft;
                GUILayout.Label(new GUIContent("Name: " + bundle.name), leftStyle);
 
                long fileSize = -1;
                if(SingleBundleInspector.currentPath != string.Empty && File.Exists(SingleBundleInspector.currentPath) )
                {
                    System.IO.FileInfo fileInfo = new System.IO.FileInfo(SingleBundleInspector.currentPath);
                    fileSize = fileInfo.Length;
                }
 
                if (fileSize < 0)
                    GUILayout.Label(new GUIContent("Size: unknown"), leftStyle);
                else
                    GUILayout.Label(new GUIContent("Size: " + EditorUtility.FormatBytes(fileSize)), leftStyle);
 
            }
 
            base.OnInspectorGUI();
        }
    }
}