少年修仙传客户端基础资源
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
using UnityEditor;
using UnityEditor.IMGUI.Controls;
using System.Collections.Generic;
using System.IO;
using System;
 
namespace UnityEngine.AssetBundles
{
    public class InspectTreeItem : TreeViewItem
    {
        private string m_BundlePath;
        public string bundlePath
        {
            get { return m_BundlePath; }
        }
        private AssetBundle m_Bundle;
 
        private AssetBundleInspectTab m_InspectTab;
        //public InspectTreeItem(int id, int depth, string displayName) : base(id, depth, displayName)
        public InspectTreeItem(string path, AssetBundleInspectTab inspectTab) : base(path.GetHashCode(), 0, path)
        {
            m_BundlePath = path;
            m_Bundle = null;
            m_InspectTab = inspectTab;
        }
        public AssetBundle bundle
        {
            get
            {
                if (m_Bundle == null)
                    LoadBundle();
                return m_Bundle;
            }
        }
        public void LoadBundle()
        {
            if (m_Bundle == null)
            {
                m_Bundle = AssetBundle.LoadFromFile(m_BundlePath);
                m_InspectTab.SaveBundle(m_Bundle);
 
                //AssetBundleManifest manifest = m_Bundle.LoadAsset<AssetBundleManifest>("AssetBundleManifest");
                //if (manifest != null)
                //{
                //    //this is where we could get some overall data. if we wanted it. which we might. someday.
                //}
 
 
                //gotta actually load assets to keep inspector from crashing :(
                var content = m_Bundle.GetAllAssetNames();
                foreach (var c in content)
                {
                    m_Bundle.LoadAsset(c);
                }
            }
        }
    }
 
    class InspectBundleTree : TreeView
    {
        AssetBundleInspectTab m_InspectTab;
        public InspectBundleTree(TreeViewState s, AssetBundleInspectTab parent) : base(s)
        {
            m_InspectTab = parent;
            showBorder = true;
        }
 
        protected override TreeViewItem BuildRoot()
        {
            var root = new TreeViewItem(-1, -1);
            root.children = new List<TreeViewItem>();
            if (m_InspectTab == null)
                DebugEx.Log("Unknown problem in AssetBundle Browser Inspect tab.  Restart Browser and try again, or file ticket on github.");
            else
            {
                foreach (var b in m_InspectTab.BundleList)
                {
                    root.AddChild(new InspectTreeItem(b, m_InspectTab));
                }
            }
            return root;
        }
 
        public override void OnGUI(Rect rect)
        {
            base.OnGUI(rect);
            if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && rect.Contains(Event.current.mousePosition))
            {
                SetSelection(new int[0], TreeViewSelectionOptions.FireSelectionChanged);
            }
        }
 
        protected override void SelectionChanged(IList<int> selectedIds)
        {
            base.SelectionChanged(selectedIds);
            
            if (selectedIds.Count > 0)
            {
                m_InspectTab.SetBundleItem(FindItem(selectedIds[0], rootItem) as InspectTreeItem);
            }
            else
                m_InspectTab.SetBundleItem(null);
        }
 
        protected override bool CanMultiSelect(TreeViewItem item)
        {
            return false;
        }
    }
 
}