2026/6/20 1:17:23
网站建设
项目流程
网站建设logo显示怎么设置,这么开网站,网页推广方案,即时设计广告GitHub地址 当在 窗口中选中资源时#xff0c;实现 同步选中Assets下的资源对象的功能#xff1a;
修改 AssetTreeView脚本 为#xff1a;
using UnityEngine;
using UnityEditor;
using UnityEditor.IMGUI.Controls;
using System.Collections.Generic;// 带数据的 Tree…GitHub地址当在 窗口中选中资源时实现 同步选中Assets下的资源对象的功能修改AssetTreeView脚本为usingUnityEngine;usingUnityEditor;usingUnityEditor.IMGUI.Controls;usingSystem.Collections.Generic;// 带数据的 TreeViewItempublicclassAssetViewItem:TreeViewItem{publicReferenceFinderData.AssetDescriptiondata;}// 资源引用树publicclassAssetTreeView:TreeView{constfloatkIconWidth18f;constfloatkRowHeights20f;publicAssetViewItemassetRoot;privateGUIStylestateGUIStylenewGUIStyle{richTexttrue,alignmentTextAnchor.MiddleCenter};enumMyColumns{Name,Path,State,}publicAssetTreeView(TreeViewStatestate,MultiColumnHeadermulticolumnHeader):base(state,multicolumnHeader){rowHeightkRowHeights;columnIndexForTreeFoldouts0;showAlternatingRowBackgroundstrue;showBorderfalse;customFoldoutYOffset(kRowHeights-EditorGUIUtility.singleLineHeight)*0.5f;extraSpaceBeforeIconAndLabelkIconWidth;}// 新增选中同步到 Project protectedoverridevoidSelectionChanged(IListintselectedIds){if(selectedIdsnull||selectedIds.Count0)return;ListObjectobjectsnewListObject();foreach(varidinselectedIds){varitemFindItem(id,rootItem)asAssetViewItem;if(itemnull||item.datanull)continue;stringpathitem.data.path;if(string.IsNullOrEmpty(path))continue;varobjAssetDatabase.LoadAssetAtPathObject(path);if(obj!null)objects.Add(obj);}if(objects.Count0){Selection.objectsobjects.ToArray();EditorGUIUtility.PingObject(objects[0]);}}// protectedoverridevoidContextClickedItem(intid){SetExpanded(id,!IsExpanded(id));}protectedoverridevoidDoubleClickedItem(intid){varitemFindItem(id,rootItem)asAssetViewItem;if(item!nullitem.data!null){varassetObjectAssetDatabase.LoadAssetAtPathObject(item.data.path);if(assetObject!null){EditorUtility.FocusProjectWindow();Selection.activeObjectassetObject;EditorGUIUtility.PingObject(assetObject);}}}publicstaticMultiColumnHeaderStateCreateDefaultMultiColumnHeaderState(floattreeViewWidth){varcolumnsnew[]{newMultiColumnHeaderState.Column{headerContentnewGUIContent(Name),headerTextAlignmentTextAlignment.Center,width200,minWidth60,autoResizefalse,allowToggleVisibilityfalse,canSortfalse},newMultiColumnHeaderState.Column{headerContentnewGUIContent(Path),headerTextAlignmentTextAlignment.Center,width360,minWidth60,autoResizefalse,allowToggleVisibilityfalse,canSortfalse},newMultiColumnHeaderState.Column{headerContentnewGUIContent(State),headerTextAlignmentTextAlignment.Center,width60,minWidth60,autoResizefalse,allowToggleVisibilitytrue,canSortfalse},};returnnewMultiColumnHeaderState(columns);}protectedoverrideTreeViewItemBuildRoot(){returnassetRoot;}protectedoverridevoidRowGUI(RowGUIArgsargs){varitem(AssetViewItem)args.item;for(inti0;iargs.GetNumVisibleColumns();i){CellGUI(args.GetCellRect(i),item,(MyColumns)args.GetColumn(i),refargs);}}voidCellGUI(RectcellRect,AssetViewItemitem,MyColumnscolumn,refRowGUIArgsargs){CenterRectUsingSingleLineHeight(refcellRect);switch(column){caseMyColumns.Name:variconRectcellRect;iconRect.xGetContentIndent(item);iconRect.widthkIconWidth;if(iconRect.xcellRect.xMax){variconGetIcon(item.data.path);if(icon!null)GUI.DrawTexture(iconRect,icon,ScaleMode.ScaleToFit);}args.rowRectcellRect;base.RowGUI(args);break;caseMyColumns.Path:GUI.Label(cellRect,item.data.path);break;caseMyColumns.State:GUI.Label(cellRect,ReferenceFinderData.GetInfoByState(item.data.state),stateGUIStyle);break;}}privateTexture2DGetIcon(stringpath){ObjectobjAssetDatabase.LoadAssetAtPathObject(path);if(obj!null){Texture2DiconAssetPreview.GetMiniThumbnail(obj);if(iconnull)iconAssetPreview.GetMiniTypeThumbnail(obj.GetType());returnicon;}returnnull;}}