news 2026/5/9 1:53:39

Unity ReferenceFinder插件 窗口中选择资源时 同步选择Assets下的资源

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
Unity ReferenceFinder插件 窗口中选择资源时 同步选择Assets下的资源

GitHub地址


当在 窗口中选中资源时,实现 同步选中Assets下的资源对象的功能:

修改AssetTreeView脚本为:

usingUnityEngine;usingUnityEditor;usingUnityEditor.IMGUI.Controls;usingSystem.Collections.Generic;// 带数据的 TreeViewItempublicclassAssetViewItem:TreeViewItem{publicReferenceFinderData.AssetDescriptiondata;}// 资源引用树publicclassAssetTreeView:TreeView{constfloatkIconWidth=18f;constfloatkRowHeights=20f;publicAssetViewItemassetRoot;privateGUIStylestateGUIStyle=newGUIStyle{richText=true,alignment=TextAnchor.MiddleCenter};enumMyColumns{Name,Path,State,}publicAssetTreeView(TreeViewStatestate,MultiColumnHeadermulticolumnHeader):base(state,multicolumnHeader){rowHeight=kRowHeights;columnIndexForTreeFoldouts=0;showAlternatingRowBackgrounds=true;showBorder=false;customFoldoutYOffset=(kRowHeights-EditorGUIUtility.singleLineHeight)*0.5f;extraSpaceBeforeIconAndLabel=kIconWidth;}// ================== 新增:选中同步到 Project ==================protectedoverridevoidSelectionChanged(IList<int>selectedIds){if(selectedIds==null||selectedIds.Count==0)return;List<Object>objects=newList<Object>();foreach(varidinselectedIds){varitem=FindItem(id,rootItem)asAssetViewItem;if(item==null||item.data==null)continue;stringpath=item.data.path;if(string.IsNullOrEmpty(path))continue;varobj=AssetDatabase.LoadAssetAtPath<Object>(path);if(obj!=null)objects.Add(obj);}if(objects.Count>0){Selection.objects=objects.ToArray();EditorGUIUtility.PingObject(objects[0]);}}// =============================================================protectedoverridevoidContextClickedItem(intid){SetExpanded(id,!IsExpanded(id));}protectedoverridevoidDoubleClickedItem(intid){varitem=FindItem(id,rootItem)asAssetViewItem;if(item!=null&&item.data!=null){varassetObject=AssetDatabase.LoadAssetAtPath<Object>(item.data.path);if(assetObject!=null){EditorUtility.FocusProjectWindow();Selection.activeObject=assetObject;EditorGUIUtility.PingObject(assetObject);}}}publicstaticMultiColumnHeaderStateCreateDefaultMultiColumnHeaderState(floattreeViewWidth){varcolumns=new[]{newMultiColumnHeaderState.Column{headerContent=newGUIContent("Name"),headerTextAlignment=TextAlignment.Center,width=200,minWidth=60,autoResize=false,allowToggleVisibility=false,canSort=false},newMultiColumnHeaderState.Column{headerContent=newGUIContent("Path"),headerTextAlignment=TextAlignment.Center,width=360,minWidth=60,autoResize=false,allowToggleVisibility=false,canSort=false},newMultiColumnHeaderState.Column{headerContent=newGUIContent("State"),headerTextAlignment=TextAlignment.Center,width=60,minWidth=60,autoResize=false,allowToggleVisibility=true,canSort=false},};returnnewMultiColumnHeaderState(columns);}protectedoverrideTreeViewItemBuildRoot(){returnassetRoot;}protectedoverridevoidRowGUI(RowGUIArgsargs){varitem=(AssetViewItem)args.item;for(inti=0;i<args.GetNumVisibleColumns();++i){CellGUI(args.GetCellRect(i),item,(MyColumns)args.GetColumn(i),refargs);}}voidCellGUI(RectcellRect,AssetViewItemitem,MyColumnscolumn,refRowGUIArgsargs){CenterRectUsingSingleLineHeight(refcellRect);switch(column){caseMyColumns.Name:variconRect=cellRect;iconRect.x+=GetContentIndent(item);iconRect.width=kIconWidth;if(iconRect.x<cellRect.xMax){varicon=GetIcon(item.data.path);if(icon!=null)GUI.DrawTexture(iconRect,icon,ScaleMode.ScaleToFit);}args.rowRect=cellRect;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){Objectobj=AssetDatabase.LoadAssetAtPath<Object>(path);if(obj!=null){Texture2Dicon=AssetPreview.GetMiniThumbnail(obj);if(icon==null)icon=AssetPreview.GetMiniTypeThumbnail(obj.GetType());returnicon;}returnnull;}}
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/5/9 1:53:51

python脚本攻击Easy File Sharing Web Server

Easy File Sharing Web Server 是一款轻量级的 Windows 平台文件共享工具&#xff0c;支持通过 Web 浏览器快速搭建文件传输服务&#xff0c;无需复杂配置即可实现局域网或公网的文件上传、下载、管理功能。安全风险这款工具曾被曝出多个高危漏洞&#xff0c;包括&#xff1a;缓…

作者头像 李华
网站建设 2026/5/9 2:52:20

信捷XDM PLC三轴可编程运动控制:打造灵活数控体验

信捷xdm plc三轴可编程运动控制程序&#xff0c;支持信捷XDM系列PLC 信捷TG765触摸屏 支持直线插补 &#xff0c;圆弧插补&#xff0c;延时&#xff0c;等待输入ON&#xff0c;等待输入OFF&#xff0c;执行输出ON&#xff0c;执行输出OFF。可视化加工轨迹&#xff0c;支持电子手…

作者头像 李华
网站建设 2026/5/9 3:07:10

高斯变迹光栅滤波器模型建立及其FDTD模型与参考文献

高斯变迹光栅滤波器模型建立&#xff0c;fdtd模型参考文献光纤传感领域最近有个挺有意思的讨论热点——如何用高斯变迹光栅实现更干净的光谱响应。今天咱们就扒开这个黑盒子&#xff0c;用FDTD实战演练下这类滤波器的建模过程。先扔个结论&#xff1a;变迹本质就是给光栅结构加…

作者头像 李华
网站建设 2026/5/9 1:53:52

YOLOv8+PyQt5西红柿成熟度检测(可以重新训练,yolov8模型,从图像、视频和摄像头三种路径识别检测,包含登陆页面、注册页面和检测页面)

https://www.bilibili.com/video/BV1sr421j7w4/?spm_id_from333.999.0.0 资源包含可视化的西红柿成熟度检测系统&#xff0c;基于最新的YOLOv8训练的西红柿成熟度检测模型&#xff0c;和基于PyQt5制作的可视化西红柿成熟度检测系统&#xff0c;包含登陆页面、注册页面和检测页…

作者头像 李华
网站建设 2026/5/9 2:03:45

当AI开始“说人话“:微软VibeVoice如何让机器300毫秒内开口

你有没有想过&#xff0c;为什么Siri、小爱同学们总要"思考"一会儿才开口&#xff1f;而人类对话时&#xff0c;几乎是无缝衔接的。今天&#xff0c;我们要聊的这个项目&#xff0c;正在改变这一切。 一、从"哑巴AI"到"话痨机器人"的进化史 还记…

作者头像 李华