634 相似图片搜索工具体验优化 只有在打开工具时,拦截对image source的点击
| | |
| | | |
| | | public static void FindFromImage(UnityEngine.UI.Image target) |
| | | { |
| | | if (target == null || target.sprite == null) |
| | | if (target == null || target.sprite == null || !HasOpenInstances<SpriteSimilarityFinder>()) |
| | | return; |
| | | string path = AssetDatabase.GetAssetPath(target.sprite); |
| | | var window = GetWindow<SpriteSimilarityFinder>("相似图片查找"); |
| | |
| | | GUILayout.Label("从 Unity 菜单“程序 → 相似图片查找”打开工具。首次使用点击“重建指纹库”,等待构建完成。工具会扫描 Assets/ResourcesOut/Sprite 下的 PNG,并一起生成指纹与九宫格缓存。已有有效缓存时可直接开始查询。", EditorStyles.wordWrappedLabel); |
| | | EditorGUILayout.Space(); |
| | | GUILayout.Label("2. 选择要查找的原图", EditorStyles.boldLabel); |
| | | GUILayout.Label("想替换界面中的图片:选中场景或预制体编辑模式中的对象,在 Inspector 中左键点击 ImageEx 的 Source Image 资源名,工具会查询该图片,并显示“替换目标”。\n只想找相似资源:在 Project 中选中图片,点击“开始查找”。开启设置中的“跟随选择自动查询”后,切换图片会自动查询,结果列表回到顶部。", EditorStyles.wordWrappedLabel); |
| | | GUILayout.Label("想替换界面中的图片:先打开本工具,再选中场景或预制体编辑模式中的对象,在 Inspector 中左键点击 ImageEx 的 Source Image 资源名,工具会查询该图片,并显示“替换目标”。工具关闭时,点击资源名保留 Unity 原行为,不会自动打开工具。\n只想找相似资源:在 Project 中选中图片,点击“开始查找”。开启设置中的“跟随选择自动查询”后,切换图片会自动查询,结果列表回到顶部。", EditorStyles.wordWrappedLabel); |
| | | EditorGUILayout.Space(); |
| | | GUILayout.Label("3. 挑选候选图片", EditorStyles.boldLabel); |
| | | GUILayout.Label("对照顶部原图,查看结果的预览、图片名和图集目录。工具优先展示当前图片所属顶层目录之外的候选,例如 FairySiege 下的原图会优先展示 Common、Guild 等其他目录的图片。\n点击候选预览图可在 Project 中定位资源;点击图片名可复制名称,不含扩展名。定位候选后仍可继续为原来的目标选择替换图。", EditorStyles.wordWrappedLabel); |
| | |
| | | Rect marker = GUILayoutUtility.GetRect(0f, 0f, GUILayout.ExpandWidth(true)); |
| | | Rect spriteNameRect = new Rect(marker.x + EditorGUIUtility.labelWidth, marker.yMax + EditorGUIUtility.standardVerticalSpacing, marker.width - EditorGUIUtility.labelWidth - 20f, EditorGUIUtility.singleLineHeight); |
| | | ImageEx image = (ImageEx)target; |
| | | if (targets.Length == 1 && image.sprite != null) |
| | | if (targets.Length == 1 && image.sprite != null && EditorWindow.HasOpenInstances<SpriteSimilarityFinder>()) |
| | | { |
| | | EditorGUIUtility.AddCursorRect(spriteNameRect, MouseCursor.Link); |
| | | Event current = Event.current; |