private void AddAssetToGroup(IList <string> names) { assets.Clear(); if (!string.IsNullOrEmpty(groupName)) { string[] datas = AssetMode.resInfo.GetAssetsNames(groupName); AddAsset(datas); } else { return; } List <int> assetNames = new List <int>(); List <AssetMode.AssetInfo> infos = new List <AssetMode.AssetInfo>(); foreach (string asName in names) { AssetMode.AssetInfo info = assets.Find(a => a.Name == asName); assetNames.Add(info.NameHashCode); infos.Add(info); } ReloadAndSelect(assetNames); UpdateSelectedAssets(infos); }
/// <summary> /// 从新加载 /// </summary> public void Reload() { mCurrentSelectAssets = null; if (preEditor != null) { //Resources.UnloadAsset(preEditor); Object.DestroyImmediate(preEditor); preEditor = null; } }
public void AddAsset(string[] datas) { int id = 0; foreach (string str in datas) { AssetMode.AssetInfo info = new AssetMode.AssetInfo(id++, str); assets.Add(info); } }
internal void SelectedAssets(AssetMode.AssetInfo info) { if (info == null) { Reload(); } else { if (mCurrentSelectAssets == null || mCurrentSelectAssets.data.path != info.data.path) { if (preEditor != null) { //Resources.UnloadAsset(preEditor); Object.DestroyImmediate(preEditor); preEditor = null; } mCurrentSelectAssets = info; } } }
public void SelectAB(string abName) { this.assets.Clear(); if (string.IsNullOrEmpty(abName)) { Reload(); return; } var assets = AssetMode.getABAssets(abName); int id = 0; foreach (var a in assets) { id++; AssetMode.AssetInfo assetInfo = new AssetMode.AssetInfo(id, a.address); //assetInfo.data = a; this.assets.Add(assetInfo); } Reload(); }
protected override TreeViewItem BuildRoot() { //AssetMode.Rebuild(); int id = 0; assets.Clear(); foreach (var str in AssetMode.resInfo.GetAssetsNames(this.groupName)) { AssetMode.AssetInfo info = new AssetMode.AssetInfo(id++, str); assets.Add(info); } var root = new TreeViewItem(); root.children = new System.Collections.Generic.List <UnityEditor.IMGUI.Controls.TreeViewItem>(); root.id = -1; root.depth = -1; foreach (AssetMode.AssetInfo asset in assets) { root.children.Add(new AssetTreeViewItem(asset)); } return(root); }
public AssetTreeViewItem(AssetMode.AssetInfo info) : base(info.NameHashCode, info.NameHashCode, info.Name) { m_asset = info; icon = AssetDatabase.GetCachedIcon(info.data.path) as Texture2D; }