119 lines
3.4 KiB
C#
119 lines
3.4 KiB
C#
#if UNITY_2019_4_OR_NEWER
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Collections.Generic;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
using UnityEditor.UIElements;
|
|
using UnityEngine.UIElements;
|
|
|
|
namespace YooAsset.Editor
|
|
{
|
|
public class AssetBundleBrowserWindow : EditorWindow
|
|
{
|
|
[MenuItem("YooAsset/AssetBundle Browser", false, 103)]
|
|
public static void ShowExample()
|
|
{
|
|
AssetBundleBrowserWindow wnd = GetWindow<AssetBundleBrowserWindow>();
|
|
wnd.titleContent = new GUIContent("栗都관啞응묏야");
|
|
wnd.minSize = new Vector2(800, 600);
|
|
}
|
|
|
|
private enum EShowMode
|
|
{
|
|
AssetList,
|
|
BundleList,
|
|
}
|
|
|
|
private ToolbarMenu _showModeMenu;
|
|
private AssetListViewer _assetListViewer;
|
|
private BundleListViewer _bundleListViewer;
|
|
|
|
private EShowMode _showMode;
|
|
private string _searchKeyWord;
|
|
private PatchManifest _manifest;
|
|
|
|
|
|
public void CreateGUI()
|
|
{
|
|
VisualElement root = this.rootVisualElement;
|
|
|
|
// 속潼꼈애匡숭
|
|
string uxml = "Assets/YooAsset/Editor/AssetBundleBrowser/AssetBundleBrowser.uxml";
|
|
var visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
|
|
if (visualAsset == null)
|
|
{
|
|
Debug.LogError($"Not found AssetBundleBrowser.uxml : {uxml}");
|
|
return;
|
|
}
|
|
visualAsset.CloneTree(root);
|
|
|
|
// 돔흙객큐
|
|
var importBtn = root.Q<Button>("ImportButton");
|
|
importBtn.clicked += ImportBtn_onClick;
|
|
|
|
// 鞫刻친駕꽉데
|
|
_showModeMenu = root.Q<ToolbarMenu>("ShowModeMenu");
|
|
_showModeMenu.menu.AppendAction(EShowMode.AssetList.ToString(), ShowModeMenuAction1);
|
|
_showModeMenu.menu.AppendAction(EShowMode.BundleList.ToString(), ShowModeMenuAction2);
|
|
|
|
// 鎧乞으
|
|
var searchField = root.Q<ToolbarPopupSearchField>("SearchField");
|
|
searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
|
|
|
|
// 속潼女충
|
|
_assetListViewer = new AssetListViewer();
|
|
_assetListViewer.InitViewer();
|
|
|
|
// 속潼女충
|
|
_bundleListViewer = new BundleListViewer();
|
|
_bundleListViewer.InitViewer();
|
|
|
|
// 놓迦女충
|
|
_showMode = EShowMode.AssetList;
|
|
_showModeMenu.text = EShowMode.AssetList.ToString();
|
|
_assetListViewer.AttachParent(root);
|
|
}
|
|
|
|
private void ImportBtn_onClick()
|
|
{
|
|
string selectFilePath = EditorUtility.OpenFilePanel("돔흙껸땀헌데", EditorTools.GetProjectPath(), "bytes");
|
|
if (string.IsNullOrEmpty(selectFilePath))
|
|
return;
|
|
|
|
string jsonData = FileUtility.ReadFile(selectFilePath);
|
|
_manifest = PatchManifest.Deserialize(jsonData);
|
|
_assetListViewer.FillViewData(_manifest, _searchKeyWord);
|
|
_bundleListViewer.FillViewData(_manifest, _searchKeyWord);
|
|
}
|
|
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
|
{
|
|
_searchKeyWord = e.newValue;
|
|
_assetListViewer.FillViewData(_manifest, _searchKeyWord);
|
|
_bundleListViewer.FillViewData(_manifest, _searchKeyWord);
|
|
}
|
|
private void ShowModeMenuAction1(DropdownMenuAction action)
|
|
{
|
|
if (_showMode != EShowMode.AssetList)
|
|
{
|
|
_showMode = EShowMode.AssetList;
|
|
VisualElement root = this.rootVisualElement;
|
|
_showModeMenu.text = EShowMode.AssetList.ToString();
|
|
_bundleListViewer.DetachParent();
|
|
_assetListViewer.AttachParent(root);
|
|
}
|
|
}
|
|
private void ShowModeMenuAction2(DropdownMenuAction action)
|
|
{
|
|
if (_showMode != EShowMode.BundleList)
|
|
{
|
|
_showMode = EShowMode.BundleList;
|
|
VisualElement root = this.rootVisualElement;
|
|
_showModeMenu.text = EShowMode.BundleList.ToString();
|
|
_assetListViewer.DetachParent();
|
|
_bundleListViewer.AttachParent(root);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endif |