com.jaimecamachodev.unityfolders 1.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.attestation.p7m +0 -0
- package/Editor/FolderIconRecolorUtility.cs +71 -0
- package/Editor/FolderIconRecolorUtility.cs.meta +2 -0
- package/Editor/FolderIconsManager.cs +168 -0
- package/Editor/FolderIconsManager.cs.meta +2 -0
- package/Editor/FolderIconsPostprocessor.cs +14 -0
- package/Editor/FolderIconsPostprocessor.cs.meta +2 -0
- package/Editor/FolderIconsSettings.cs +40 -0
- package/Editor/FolderIconsSettings.cs.meta +2 -0
- package/Editor/FolderIconsSettingsEditor.cs +147 -0
- package/Editor/FolderIconsSettingsEditor.cs.meta +2 -0
- package/Editor/FolderIconsSettingsMenu.cs +35 -0
- package/Editor/FolderIconsSettingsMenu.cs.meta +2 -0
- package/Editor/UnityAssetsRenamer.cs +70 -0
- package/Editor/UnityAssetsRenamer.cs.meta +11 -0
- package/Editor/UnityFolderOrganizer.cs +215 -0
- package/Editor/UnityFolderOrganizer.cs.meta +2 -0
- package/Editor/UnityFoldersCreator.cs +118 -0
- package/Editor/UnityFoldersCreator.cs.meta +2 -0
- package/Editor/UnityMaterialsCreator.cs +386 -0
- package/Editor/UnityMaterialsCreator.cs.meta +11 -0
- package/Editor/UnityMaterialsOrganizerRenamer.cs +63 -0
- package/Editor/UnityMaterialsOrganizerRenamer.cs.meta +11 -0
- package/Editor/UnityOrganizeAndRenamer.cs +58 -0
- package/Editor/UnityOrganizeAndRenamer.cs.meta +11 -0
- package/Editor/UnityPrefabCreator.cs +128 -0
- package/Editor/UnityPrefabCreator.cs.meta +11 -0
- package/Editor/UnityProjectStructureCreator.cs +51 -0
- package/Editor/UnityProjectStructureCreator.cs.meta +2 -0
- package/Editor/com.jaimecamacho.unityfolders.Editor.asmdef +16 -0
- package/Editor/com.jaimecamacho.unityfolders.Editor.asmdef.meta +7 -0
- package/Editor.meta +8 -0
- package/FolderIconsSettings/FolderIconsSettings.asset +292 -0
- package/FolderIconsSettings/FolderIconsSettings.asset.meta +8 -0
- package/FolderIconsSettings.meta +8 -0
- package/Folders/5-Skyboxs_Large_tint.png +0 -0
- package/Folders/5-Skyboxs_Large_tint.png.meta +156 -0
- package/Folders/5-Skyboxs_Small_tint.png +0 -0
- package/Folders/5-Skyboxs_Small_tint.png.meta +156 -0
- package/Folders.meta +8 -0
- package/Icons/Animations.png +0 -0
- package/Icons/Animations.png.meta +156 -0
- package/Icons/Audio.png +0 -0
- package/Icons/Audio.png.meta +156 -0
- package/Icons/Editor.png +0 -0
- package/Icons/Editor.png.meta +156 -0
- package/Icons/Fonts.png +0 -0
- package/Icons/Fonts.png.meta +156 -0
- package/Icons/Materials.png +0 -0
- package/Icons/Materials.png.meta +156 -0
- package/Icons/Models.png +0 -0
- package/Icons/Models.png.meta +156 -0
- package/Icons/Plugins.png +0 -0
- package/Icons/Plugins.png.meta +156 -0
- package/Icons/Prefabs.png +0 -0
- package/Icons/Prefabs.png.meta +156 -0
- package/Icons/Presets.png +0 -0
- package/Icons/Presets.png.meta +156 -0
- package/Icons/Resources.png +0 -0
- package/Icons/Resources.png.meta +156 -0
- package/Icons/Scenes.png +0 -0
- package/Icons/Scenes.png.meta +156 -0
- package/Icons/Scripts.png +0 -0
- package/Icons/Scripts.png.meta +156 -0
- package/Icons/Settings.png +0 -0
- package/Icons/Settings.png.meta +156 -0
- package/Icons/Shaders.png +0 -0
- package/Icons/Shaders.png.meta +156 -0
- package/Icons/Sprites.png +0 -0
- package/Icons/Sprites.png.meta +156 -0
- package/Icons/Textures.png +0 -0
- package/Icons/Textures.png.meta +156 -0
- package/Icons/X16/-Test14.png +0 -0
- package/Icons/X16/-Test14.png.meta +130 -0
- package/Icons/X16/-Test3.png +0 -0
- package/Icons/X16/-Test3.png.meta +130 -0
- package/Icons/X16/1-3D.png +0 -0
- package/Icons/X16/1-3D.png.meta +130 -0
- package/Icons/X16/1-Programming.png +0 -0
- package/Icons/X16/1-Programming.png.meta +130 -0
- package/Icons/X16/10-Lighting.png +0 -0
- package/Icons/X16/10-Lighting.png.meta +130 -0
- package/Icons/X16/2-Art.png +0 -0
- package/Icons/X16/2-Art.png.meta +130 -0
- package/Icons/X16/2-VFX V2.png +0 -0
- package/Icons/X16/2-VFX V2.png.meta +130 -0
- package/Icons/X16/2-VFX.png +0 -0
- package/Icons/X16/2-VFX.png.meta +130 -0
- package/Icons/X16/3-SFX.png +0 -0
- package/Icons/X16/3-SFX.png.meta +130 -0
- package/Icons/X16/3-Scenes.png +0 -0
- package/Icons/X16/3-Scenes.png.meta +130 -0
- package/Icons/X16/4-Directors.png +0 -0
- package/Icons/X16/4-Directors.png.meta +130 -0
- package/Icons/X16/4-Presets.png +0 -0
- package/Icons/X16/4-Presets.png.meta +130 -0
- package/Icons/X16/5-Settings.png +0 -0
- package/Icons/X16/5-Settings.png.meta +130 -0
- package/Icons/X16/5-Skyboxes v2.png +0 -0
- package/Icons/X16/5-Skyboxes v2.png.meta +130 -0
- package/Icons/X16/5-Skyboxes.png +0 -0
- package/Icons/X16/5-Skyboxes.png.meta +130 -0
- package/Icons/X16/6-Videos.png +0 -0
- package/Icons/X16/6-Videos.png.meta +130 -0
- package/Icons/X16/7-SolidMats.png +0 -0
- package/Icons/X16/7-SolidMats.png.meta +130 -0
- package/Icons/X16/8-PostProcessing.png +0 -0
- package/Icons/X16/8-PostProcessing.png.meta +130 -0
- package/Icons/X16/9-UI.png +0 -0
- package/Icons/X16/9-UI.png.meta +130 -0
- package/Icons/X16/Animation_X16.png +0 -0
- package/Icons/X16/Animation_X16.png.meta +130 -0
- package/Icons/X16/Art_X16.png +0 -0
- package/Icons/X16/Art_X16.png.meta +130 -0
- package/Icons/X16/Audio_X16.png +0 -0
- package/Icons/X16/Audio_X16.png.meta +130 -0
- package/Icons/X16/C_Animation_X16.png +0 -0
- package/Icons/X16/C_Animation_X16.png.meta +130 -0
- package/Icons/X16/C_Audio_X16.png +0 -0
- package/Icons/X16/C_Audio_X16.png.meta +130 -0
- package/Icons/X16/C_Material_X16.png +0 -0
- package/Icons/X16/C_Material_X16.png.meta +130 -0
- package/Icons/X16/C_Mesh_X16.png +0 -0
- package/Icons/X16/C_Mesh_X16.png.meta +130 -0
- package/Icons/X16/C_Prefab_X16.png +0 -0
- package/Icons/X16/C_Prefab_X16.png.meta +130 -0
- package/Icons/X16/C_Script_X16.png +0 -0
- package/Icons/X16/C_Script_X16.png.meta +130 -0
- package/Icons/X16/C_VFX_X16.png +0 -0
- package/Icons/X16/C_VFX_X16.png.meta +130 -0
- package/Icons/X16/Director_X16.png +0 -0
- package/Icons/X16/Director_X16.png.meta +130 -0
- package/Icons/X16/Folder_X16.png +0 -0
- package/Icons/X16/Folder_X16.png.meta +130 -0
- package/Icons/X16/Light_X16.png +0 -0
- package/Icons/X16/Light_X16.png.meta +130 -0
- package/Icons/X16/Material_X16.png +0 -0
- package/Icons/X16/Material_X16.png.meta +130 -0
- package/Icons/X16/Mesh_X16.png +0 -0
- package/Icons/X16/Mesh_X16.png.meta +130 -0
- package/Icons/X16/PostPro_X16.png +0 -0
- package/Icons/X16/PostPro_X16.png.meta +130 -0
- package/Icons/X16/Prefab_X16.png +0 -0
- package/Icons/X16/Prefab_X16.png.meta +130 -0
- package/Icons/X16/Preset2_X16.png +0 -0
- package/Icons/X16/Preset2_X16.png.meta +130 -0
- package/Icons/X16/Preset_X16.png +0 -0
- package/Icons/X16/Preset_X16.png.meta +130 -0
- package/Icons/X16/SFX_X16.png +0 -0
- package/Icons/X16/SFX_X16.png.meta +130 -0
- package/Icons/X16/Scene_X16.png +0 -0
- package/Icons/X16/Scene_X16.png.meta +130 -0
- package/Icons/X16/Script_X16.png +0 -0
- package/Icons/X16/Script_X16.png.meta +130 -0
- package/Icons/X16/Settings2_X16.png +0 -0
- package/Icons/X16/Settings2_X16.png.meta +130 -0
- package/Icons/X16/Settings3_X16.png +0 -0
- package/Icons/X16/Settings3_X16.png.meta +130 -0
- package/Icons/X16/Settings_X16.png +0 -0
- package/Icons/X16/Settings_X16.png.meta +130 -0
- package/Icons/X16/Shader_X16.png +0 -0
- package/Icons/X16/Shader_X16.png.meta +130 -0
- package/Icons/X16/Skybox_X16.png +0 -0
- package/Icons/X16/Skybox_X16.png.meta +130 -0
- package/Icons/X16/SolidMats_X16.png +0 -0
- package/Icons/X16/SolidMats_X16.png.meta +130 -0
- package/Icons/X16/Text_X16.png +0 -0
- package/Icons/X16/Text_X16.png.meta +130 -0
- package/Icons/X16/UI_X16.png +0 -0
- package/Icons/X16/UI_X16.png.meta +130 -0
- package/Icons/X16/VFX_X16.png +0 -0
- package/Icons/X16/VFX_X16.png.meta +130 -0
- package/Icons/X16/Video_X16.png +0 -0
- package/Icons/X16/Video_X16.png.meta +130 -0
- package/Icons/X16.meta +8 -0
- package/Icons/x256/1-3Dx256.png +0 -0
- package/Icons/x256/1-3Dx256.png.meta +130 -0
- package/Icons/x256/1-Programmingx256.png +0 -0
- package/Icons/x256/1-Programmingx256.png.meta +130 -0
- package/Icons/x256/10-Lightingx256.png +0 -0
- package/Icons/x256/10-Lightingx256.png.meta +130 -0
- package/Icons/x256/2-Artx256.png +0 -0
- package/Icons/x256/2-Artx256.png.meta +130 -0
- package/Icons/x256/2-VFXx256.png +0 -0
- package/Icons/x256/2-VFXx256.png.meta +130 -0
- package/Icons/x256/3-SFXx256.png +0 -0
- package/Icons/x256/3-SFXx256.png.meta +130 -0
- package/Icons/x256/3-Scenesx256.png +0 -0
- package/Icons/x256/3-Scenesx256.png.meta +130 -0
- package/Icons/x256/4-Directorsx256.png +0 -0
- package/Icons/x256/4-Directorsx256.png.meta +130 -0
- package/Icons/x256/4-Presetsx256.png +0 -0
- package/Icons/x256/4-Presetsx256.png.meta +130 -0
- package/Icons/x256/5-Settingsx256.png +0 -0
- package/Icons/x256/5-Settingsx256.png.meta +130 -0
- package/Icons/x256/5-Skyboxes v2x256.png +0 -0
- package/Icons/x256/5-Skyboxes v2x256.png.meta +130 -0
- package/Icons/x256/6-Videosx256.png +0 -0
- package/Icons/x256/6-Videosx256.png.meta +130 -0
- package/Icons/x256/7-SolidMatsx256.png +0 -0
- package/Icons/x256/7-SolidMatsx256.png.meta +130 -0
- package/Icons/x256/8-PostProcessingx256.png +0 -0
- package/Icons/x256/8-PostProcessingx256.png.meta +130 -0
- package/Icons/x256/9-UIx256.png +0 -0
- package/Icons/x256/9-UIx256.png.meta +130 -0
- package/Icons/x256/B_Folder_White.png +0 -0
- package/Icons/x256/B_Folder_White.png.meta +130 -0
- package/Icons/x256/C_Animation_X256.png +0 -0
- package/Icons/x256/C_Animation_X256.png.meta +130 -0
- package/Icons/x256/C_Audio_X256.png +0 -0
- package/Icons/x256/C_Audio_X256.png.meta +130 -0
- package/Icons/x256/C_Material_X256.png +0 -0
- package/Icons/x256/C_Material_X256.png.meta +130 -0
- package/Icons/x256/C_Mesh_X256.png +0 -0
- package/Icons/x256/C_Mesh_X256.png.meta +130 -0
- package/Icons/x256/C_Prefab_X256.png +0 -0
- package/Icons/x256/C_Prefab_X256.png.meta +130 -0
- package/Icons/x256/C_Script_X256.png +0 -0
- package/Icons/x256/C_Script_X256.png.meta +130 -0
- package/Icons/x256/C_VFX_X256.png +0 -0
- package/Icons/x256/C_VFX_X256.png.meta +130 -0
- package/Icons/x256/Folder_White.png +0 -0
- package/Icons/x256/Folder_White.png.meta +156 -0
- package/Icons/x256/Shader_X256.png +0 -0
- package/Icons/x256/Shader_X256.png.meta +130 -0
- package/Icons/x256.meta +8 -0
- package/Icons.meta +8 -0
- package/PSD/PSD.psd +0 -0
- package/PSD/PSD.psd.meta +130 -0
- package/PSD/PSDx256.psd +0 -0
- package/PSD/PSDx256.psd.meta +130 -0
- package/PSD.meta +8 -0
- package/package.json +29 -0
- package/package.json.meta +7 -0
package/.attestation.p7m
ADDED
|
Binary file
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
using UnityEditor;
|
|
3
|
+
using System.IO;
|
|
4
|
+
|
|
5
|
+
public static class FolderIconRecolorUtility
|
|
6
|
+
{
|
|
7
|
+
public static Texture2D Recolor(Texture2D baseTex, Color tint, Texture2D overlay = null)
|
|
8
|
+
{
|
|
9
|
+
if (baseTex == null || !baseTex.isReadable)
|
|
10
|
+
{
|
|
11
|
+
Debug.LogWarning($"Texture '{baseTex?.name}' is not readable.");
|
|
12
|
+
return baseTex;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
Texture2D newTex = new Texture2D(baseTex.width, baseTex.height);
|
|
16
|
+
Color[] basePixels = baseTex.GetPixels();
|
|
17
|
+
|
|
18
|
+
for (int i = 0; i < basePixels.Length; i++)
|
|
19
|
+
{
|
|
20
|
+
Color c = basePixels[i];
|
|
21
|
+
basePixels[i] = new Color(c.r * tint.r, c.g * tint.g, c.b * tint.b, c.a);
|
|
22
|
+
}
|
|
23
|
+
newTex.SetPixels(basePixels);
|
|
24
|
+
|
|
25
|
+
if (overlay != null && overlay.isReadable)
|
|
26
|
+
{
|
|
27
|
+
int size = baseTex.width / 2;
|
|
28
|
+
int startX = (baseTex.width - size) / 2;
|
|
29
|
+
int startY = (baseTex.height - size) / 2;
|
|
30
|
+
|
|
31
|
+
for (int y = 0; y < size; y++)
|
|
32
|
+
{
|
|
33
|
+
for (int x = 0; x < size; x++)
|
|
34
|
+
{
|
|
35
|
+
int destX = startX + x;
|
|
36
|
+
int destY = startY + y;
|
|
37
|
+
Color overlayPixel = overlay.GetPixelBilinear(x / (float)size, y / (float)size);
|
|
38
|
+
Color basePixel = newTex.GetPixel(destX, destY);
|
|
39
|
+
newTex.SetPixel(destX, destY, Color.Lerp(basePixel, overlayPixel, overlayPixel.a));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
newTex.Apply();
|
|
45
|
+
return newTex;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public static Texture2D RecolorAndSave(Texture2D baseTex, Color tint, string name, Texture2D overlay = null)
|
|
49
|
+
{
|
|
50
|
+
var newTex = Recolor(baseTex, tint, overlay);
|
|
51
|
+
if (newTex == null) return baseTex;
|
|
52
|
+
|
|
53
|
+
byte[] pngData = newTex.EncodeToPNG();
|
|
54
|
+
string path = $"Packages/com.jaimecamacho.unityfolders/Folders/{name}_tint.png";
|
|
55
|
+
|
|
56
|
+
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
|
57
|
+
File.WriteAllBytes(path, pngData);
|
|
58
|
+
|
|
59
|
+
AssetDatabase.ImportAsset(path);
|
|
60
|
+
var importer = (TextureImporter)AssetImporter.GetAtPath(path);
|
|
61
|
+
if (importer != null)
|
|
62
|
+
{
|
|
63
|
+
importer.textureType = TextureImporterType.GUI;
|
|
64
|
+
importer.maxTextureSize = 256;
|
|
65
|
+
importer.isReadable = true;
|
|
66
|
+
importer.SaveAndReimport();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return AssetDatabase.LoadAssetAtPath<Texture2D>(path);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
using UnityEditor;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
using System.IO;
|
|
4
|
+
using System.Linq;
|
|
5
|
+
using System;
|
|
6
|
+
using System.Reflection;
|
|
7
|
+
|
|
8
|
+
[InitializeOnLoad]
|
|
9
|
+
public static class FolderIconsManager
|
|
10
|
+
{
|
|
11
|
+
static FolderIconsSettings settings;
|
|
12
|
+
static System.Collections.Generic.List<FolderIconRule> sortedRules;
|
|
13
|
+
static Texture2D gradientTex;
|
|
14
|
+
static Type projectBrowserType;
|
|
15
|
+
static FieldInfo lastInteractedProjectBrowserField;
|
|
16
|
+
static FieldInfo viewModeField;
|
|
17
|
+
|
|
18
|
+
static FolderIconsManager()
|
|
19
|
+
{
|
|
20
|
+
EditorApplication.projectWindowItemOnGUI += DrawCustomIcons;
|
|
21
|
+
LoadSettings();
|
|
22
|
+
CreateGradient();
|
|
23
|
+
InitReflection();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static void InitReflection()
|
|
27
|
+
{
|
|
28
|
+
projectBrowserType = typeof(Editor).Assembly.GetType("UnityEditor.ProjectBrowser");
|
|
29
|
+
lastInteractedProjectBrowserField = projectBrowserType?.GetField("s_LastInteractedProjectBrowser", BindingFlags.Static | BindingFlags.NonPublic);
|
|
30
|
+
viewModeField = projectBrowserType?.GetField("m_ViewMode", BindingFlags.Instance | BindingFlags.NonPublic);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
internal static void LoadSettings()
|
|
34
|
+
{
|
|
35
|
+
var guid = AssetDatabase.FindAssets("t:FolderIconsSettings").FirstOrDefault();
|
|
36
|
+
if (!string.IsNullOrEmpty(guid))
|
|
37
|
+
{
|
|
38
|
+
string path = AssetDatabase.GUIDToAssetPath(guid);
|
|
39
|
+
settings = AssetDatabase.LoadAssetAtPath<FolderIconsSettings>(path);
|
|
40
|
+
}
|
|
41
|
+
UpdateSortedRules();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static void UpdateSortedRules()
|
|
45
|
+
{
|
|
46
|
+
sortedRules = settings == null
|
|
47
|
+
? new System.Collections.Generic.List<FolderIconRule>()
|
|
48
|
+
: settings.rules.Where(r => r.enabled).OrderByDescending(r => r.priority).ToList();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static void CreateGradient()
|
|
52
|
+
{
|
|
53
|
+
gradientTex = new Texture2D(128, 1, TextureFormat.ARGB32, false);
|
|
54
|
+
gradientTex.wrapMode = TextureWrapMode.Clamp;
|
|
55
|
+
for (int x = 0; x < 128; x++)
|
|
56
|
+
{
|
|
57
|
+
float t = x / 127f;
|
|
58
|
+
Color c = new Color(1, 1, 1, Mathf.Lerp(0.25f, 0f, t));
|
|
59
|
+
gradientTex.SetPixel(x, 0, c);
|
|
60
|
+
}
|
|
61
|
+
gradientTex.Apply();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static bool IsInLeftColumn(Rect selectionRect)
|
|
65
|
+
{
|
|
66
|
+
if (projectBrowserType == null || lastInteractedProjectBrowserField == null || viewModeField == null)
|
|
67
|
+
return false;
|
|
68
|
+
|
|
69
|
+
var browser = lastInteractedProjectBrowserField.GetValue(null);
|
|
70
|
+
if (browser == null) return false;
|
|
71
|
+
|
|
72
|
+
int viewMode = (int)viewModeField.GetValue(browser);
|
|
73
|
+
return viewMode == 1 && selectionRect.xMax < 200f && selectionRect.height <= EditorGUIUtility.singleLineHeight + 4;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static void DrawCustomIcons(string guid, Rect selectionRect)
|
|
77
|
+
{
|
|
78
|
+
if (settings == null || sortedRules == null) return;
|
|
79
|
+
|
|
80
|
+
string path = AssetDatabase.GUIDToAssetPath(guid);
|
|
81
|
+
if (!AssetDatabase.IsValidFolder(path)) return;
|
|
82
|
+
|
|
83
|
+
string folderName = Path.GetFileName(path);
|
|
84
|
+
|
|
85
|
+
foreach (var rule in sortedRules)
|
|
86
|
+
{
|
|
87
|
+
if (!Match(rule, path, folderName)) continue;
|
|
88
|
+
|
|
89
|
+
bool isGrid = selectionRect.height > 25f && selectionRect.width > 25f;
|
|
90
|
+
bool isInLeftColumn = !isGrid && IsInLeftColumn(selectionRect);
|
|
91
|
+
Texture2D icon = isGrid ? rule.iconLarge : rule.iconSmall;
|
|
92
|
+
|
|
93
|
+
// Gradiente
|
|
94
|
+
if (rule.background.a > 0.01f)
|
|
95
|
+
{
|
|
96
|
+
Rect labelRect;
|
|
97
|
+
if (isGrid)
|
|
98
|
+
{
|
|
99
|
+
float textHeight = EditorGUIUtility.singleLineHeight;
|
|
100
|
+
float labelY = selectionRect.yMax - textHeight + 2f;
|
|
101
|
+
labelRect = new Rect(selectionRect.x, labelY, selectionRect.width, textHeight);
|
|
102
|
+
}
|
|
103
|
+
else
|
|
104
|
+
{
|
|
105
|
+
float xStart = selectionRect.x + selectionRect.height;
|
|
106
|
+
float width = selectionRect.width - (xStart - selectionRect.x);
|
|
107
|
+
width = Mathf.Max(48f, width);
|
|
108
|
+
labelRect = new Rect(xStart, selectionRect.y, width, selectionRect.height);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
GUI.color = rule.background;
|
|
112
|
+
if (gradientTex != null)
|
|
113
|
+
GUI.DrawTexture(labelRect, gradientTex, ScaleMode.StretchToFill);
|
|
114
|
+
GUI.color = Color.white;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Dibujo del icono base
|
|
118
|
+
if (icon != null)
|
|
119
|
+
{
|
|
120
|
+
Rect iconRect;
|
|
121
|
+
if (isGrid)
|
|
122
|
+
{
|
|
123
|
+
float size = selectionRect.height - EditorGUIUtility.singleLineHeight;
|
|
124
|
+
float iconX = selectionRect.x + (selectionRect.width - size) * 0.5f;
|
|
125
|
+
iconRect = new Rect(iconX - 3, selectionRect.y - 1, size + 6, size + 6);
|
|
126
|
+
}
|
|
127
|
+
else if (isInLeftColumn)
|
|
128
|
+
{
|
|
129
|
+
iconRect = new Rect(selectionRect.x, selectionRect.y, selectionRect.height, selectionRect.height);
|
|
130
|
+
}
|
|
131
|
+
else
|
|
132
|
+
{
|
|
133
|
+
iconRect = new Rect(selectionRect.x + 1, selectionRect.y - 1, selectionRect.height, selectionRect.height);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
Color prevColor = GUI.color;
|
|
137
|
+
GUI.color = new Color(0.2196f, 0.2196f, 0.2196f, 0f);
|
|
138
|
+
GUI.DrawTexture(iconRect, Texture2D.whiteTexture);
|
|
139
|
+
GUI.color = prevColor;
|
|
140
|
+
|
|
141
|
+
GUI.DrawTexture(iconRect, icon, ScaleMode.ScaleToFit, true);
|
|
142
|
+
|
|
143
|
+
// 🟡 Dibujo del overlay centrado solo en iconos grandes
|
|
144
|
+
if (rule.overlayIcon != null && isGrid)
|
|
145
|
+
{
|
|
146
|
+
float overlaySize = iconRect.width * 0.5f;
|
|
147
|
+
float overlayX = iconRect.x + (iconRect.width - overlaySize) * 0.5f;
|
|
148
|
+
float overlayY = iconRect.y + (iconRect.height - overlaySize) * 0.5f;
|
|
149
|
+
Rect overlayRect = new Rect(overlayX, overlayY, overlaySize, overlaySize);
|
|
150
|
+
GUI.DrawTexture(overlayRect, rule.overlayIcon, ScaleMode.ScaleToFit, true);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
static bool Match(FolderIconRule rule, string path, string name)
|
|
159
|
+
{
|
|
160
|
+
return rule.matchType switch
|
|
161
|
+
{
|
|
162
|
+
MatchType.Name => name.Equals(rule.match, StringComparison.OrdinalIgnoreCase),
|
|
163
|
+
MatchType.Path => path.Replace("\\", " / ").Contains(rule.match),
|
|
164
|
+
MatchType.Regex => System.Text.RegularExpressions.Regex.IsMatch(path, rule.match),
|
|
165
|
+
_ => false,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
using System.Linq;
|
|
2
|
+
using UnityEditor;
|
|
3
|
+
|
|
4
|
+
class FolderIconsPostprocessor : AssetPostprocessor
|
|
5
|
+
{
|
|
6
|
+
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
|
|
7
|
+
{
|
|
8
|
+
if (importedAssets.Concat(deletedAssets).Concat(movedAssets).Concat(movedFromAssetPaths)
|
|
9
|
+
.Any(p => p.EndsWith("FolderIconsSettings.asset")))
|
|
10
|
+
{
|
|
11
|
+
FolderIconsManager.LoadSettings();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
public class FolderIconsSettings : ScriptableObject
|
|
6
|
+
{
|
|
7
|
+
public List<FolderIconRule> rules = new();
|
|
8
|
+
|
|
9
|
+
#if UNITY_EDITOR
|
|
10
|
+
public bool showPreview = true; // A�adido para la vista previa
|
|
11
|
+
private void OnValidate()
|
|
12
|
+
{
|
|
13
|
+
FolderIconsManager.LoadSettings();
|
|
14
|
+
}
|
|
15
|
+
#endif
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
[Serializable]
|
|
19
|
+
public class FolderIconRule
|
|
20
|
+
{
|
|
21
|
+
public string ruleName = "Nueva regla";
|
|
22
|
+
public MatchType matchType = MatchType.Name;
|
|
23
|
+
public string match = "";
|
|
24
|
+
public Texture2D iconSmall;
|
|
25
|
+
public Texture2D iconLarge;
|
|
26
|
+
public Texture2D overlayIcon;
|
|
27
|
+
[HideInInspector] public Texture2D previewSmall;
|
|
28
|
+
[HideInInspector] public Texture2D previewLarge;
|
|
29
|
+
public Color background = new(1f, 1f, 1f, 0.25f);
|
|
30
|
+
public bool enabled = true;
|
|
31
|
+
public bool eraseDefault = true;
|
|
32
|
+
public int priority = 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public enum MatchType
|
|
36
|
+
{
|
|
37
|
+
Name,
|
|
38
|
+
Path,
|
|
39
|
+
Regex
|
|
40
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
using System.Collections.Generic;
|
|
2
|
+
using UnityEditor;
|
|
3
|
+
using UnityEditorInternal;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
//using JaimeCamachoDev.UnityFolders;
|
|
6
|
+
|
|
7
|
+
[CustomEditor(typeof(FolderIconsSettings))]
|
|
8
|
+
public class FolderIconsSettingsEditor : Editor
|
|
9
|
+
{
|
|
10
|
+
private ReorderableList list;
|
|
11
|
+
private readonly Dictionary<Color, Texture2D> gradientCache = new();
|
|
12
|
+
|
|
13
|
+
private Texture2D GetGradient(Color baseColor)
|
|
14
|
+
{
|
|
15
|
+
if (gradientCache.TryGetValue(baseColor, out var cached))
|
|
16
|
+
return cached;
|
|
17
|
+
|
|
18
|
+
var top = baseColor;
|
|
19
|
+
var bottom = Color.Lerp(baseColor, Color.black, 0.25f);
|
|
20
|
+
|
|
21
|
+
Texture2D tex = new Texture2D(1, 2) { wrapMode = TextureWrapMode.Clamp };
|
|
22
|
+
tex.SetPixels(new[] { top, bottom });
|
|
23
|
+
tex.Apply();
|
|
24
|
+
|
|
25
|
+
gradientCache[baseColor] = tex;
|
|
26
|
+
return tex;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private void OnEnable()
|
|
30
|
+
{
|
|
31
|
+
list = new ReorderableList(serializedObject,
|
|
32
|
+
serializedObject.FindProperty("rules"),
|
|
33
|
+
draggable: true, displayHeader: true,
|
|
34
|
+
displayAddButton: true, displayRemoveButton: true);
|
|
35
|
+
|
|
36
|
+
list.drawHeaderCallback = rect =>
|
|
37
|
+
{
|
|
38
|
+
EditorGUI.LabelField(rect, "Folder Icon Rules");
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
list.elementHeightCallback = index =>
|
|
42
|
+
{
|
|
43
|
+
|
|
44
|
+
float h = EditorGUIUtility.singleLineHeight + 4;
|
|
45
|
+
float preview = h * 2.5f;
|
|
46
|
+
return h * 7 + preview + 4; // fields + button + margin
|
|
47
|
+
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
list.drawElementCallback = (rect, index, isActive, isFocused) =>
|
|
51
|
+
{
|
|
52
|
+
var element = list.serializedProperty.GetArrayElementAtIndex(index);
|
|
53
|
+
float lineHeight = EditorGUIUtility.singleLineHeight + 4;
|
|
54
|
+
float y = rect.y;
|
|
55
|
+
|
|
56
|
+
var backgroundProp = element.FindPropertyRelative("background");
|
|
57
|
+
var iconSmallProp = element.FindPropertyRelative("iconSmall");
|
|
58
|
+
var iconLargeProp = element.FindPropertyRelative("iconLarge");
|
|
59
|
+
var overlayProp = element.FindPropertyRelative("overlayIcon");
|
|
60
|
+
var previewSmallProp = element.FindPropertyRelative("previewSmall");
|
|
61
|
+
var previewLargeProp = element.FindPropertyRelative("previewLarge");
|
|
62
|
+
|
|
63
|
+
bool updatePreview = false;
|
|
64
|
+
|
|
65
|
+
EditorGUI.PropertyField(new Rect(rect.x, y, rect.width, lineHeight), element.FindPropertyRelative("match"), new GUIContent("Match Path"));
|
|
66
|
+
y += lineHeight;
|
|
67
|
+
EditorGUI.PropertyField(new Rect(rect.x, y, rect.width, lineHeight), element.FindPropertyRelative("matchType"), new GUIContent("Match Type"));
|
|
68
|
+
y += lineHeight;
|
|
69
|
+
EditorGUI.BeginChangeCheck();
|
|
70
|
+
EditorGUI.PropertyField(new Rect(rect.x, y, rect.width, lineHeight), backgroundProp, new GUIContent("Tint Color"));
|
|
71
|
+
if (EditorGUI.EndChangeCheck()) updatePreview = true;
|
|
72
|
+
y += lineHeight;
|
|
73
|
+
EditorGUI.BeginChangeCheck();
|
|
74
|
+
EditorGUI.PropertyField(new Rect(rect.x, y, rect.width, lineHeight), iconSmallProp, new GUIContent("Icon Small"));
|
|
75
|
+
if (EditorGUI.EndChangeCheck()) updatePreview = true;
|
|
76
|
+
y += lineHeight;
|
|
77
|
+
EditorGUI.BeginChangeCheck();
|
|
78
|
+
EditorGUI.PropertyField(new Rect(rect.x, y, rect.width, lineHeight), iconLargeProp, new GUIContent("Icon Large"));
|
|
79
|
+
if (EditorGUI.EndChangeCheck()) updatePreview = true;
|
|
80
|
+
y += lineHeight;
|
|
81
|
+
EditorGUI.BeginChangeCheck();
|
|
82
|
+
EditorGUI.PropertyField(new Rect(rect.x, y, rect.width, lineHeight), overlayProp, new GUIContent("Overlay Icon"));
|
|
83
|
+
if (EditorGUI.EndChangeCheck()) updatePreview = true;
|
|
84
|
+
y += lineHeight;
|
|
85
|
+
|
|
86
|
+
if (updatePreview)
|
|
87
|
+
{
|
|
88
|
+
Texture2D small = iconSmallProp.objectReferenceValue as Texture2D;
|
|
89
|
+
Texture2D large = iconLargeProp.objectReferenceValue as Texture2D;
|
|
90
|
+
Texture2D overlay = overlayProp.objectReferenceValue as Texture2D;
|
|
91
|
+
Color bg = backgroundProp.colorValue;
|
|
92
|
+
|
|
93
|
+
previewSmallProp.objectReferenceValue = small != null ? FolderIconRecolorUtility.Recolor(small, bg) : null;
|
|
94
|
+
previewLargeProp.objectReferenceValue = large != null ? FolderIconRecolorUtility.Recolor(large, bg, overlay) : null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
var settings = (FolderIconsSettings)target;
|
|
98
|
+
if (settings.showPreview)
|
|
99
|
+
{
|
|
100
|
+
float previewSize = 32f; // Tama�o fijo a 32px
|
|
101
|
+
Rect smallRect = new Rect(rect.x, y, previewSize, previewSize);
|
|
102
|
+
Rect largeRect = new Rect(rect.x + previewSize + 4, y, previewSize, previewSize);
|
|
103
|
+
|
|
104
|
+
Texture2D smallTex = previewSmallProp.objectReferenceValue as Texture2D;
|
|
105
|
+
Texture2D largeTex = previewLargeProp.objectReferenceValue as Texture2D;
|
|
106
|
+
|
|
107
|
+
if (smallTex != null)
|
|
108
|
+
{
|
|
109
|
+
if (backgroundProp.colorValue.a > 0.01f)
|
|
110
|
+
GUI.DrawTexture(smallRect, GetGradient(backgroundProp.colorValue), ScaleMode.StretchToFill);
|
|
111
|
+
GUI.DrawTexture(smallRect, smallTex, ScaleMode.ScaleToFit, true);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (largeTex != null)
|
|
115
|
+
{
|
|
116
|
+
if (backgroundProp.colorValue.a > 0.01f)
|
|
117
|
+
GUI.DrawTexture(largeRect, GetGradient(backgroundProp.colorValue), ScaleMode.StretchToFill);
|
|
118
|
+
GUI.DrawTexture(largeRect, largeTex, ScaleMode.ScaleToFit, true);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
y += previewSize + 14;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (GUI.Button(new Rect(rect.x, y, rect.width, lineHeight), "Apply Color & Generate Icons"))
|
|
125
|
+
{
|
|
126
|
+
if (iconSmallProp.objectReferenceValue != null)
|
|
127
|
+
iconSmallProp.objectReferenceValue = FolderIconRecolorUtility.RecolorAndSave((Texture2D)iconSmallProp.objectReferenceValue, backgroundProp.colorValue, element.FindPropertyRelative("match").stringValue + "_Small");
|
|
128
|
+
if (iconLargeProp.objectReferenceValue != null)
|
|
129
|
+
iconLargeProp.objectReferenceValue = FolderIconRecolorUtility.RecolorAndSave((Texture2D)iconLargeProp.objectReferenceValue, backgroundProp.colorValue, element.FindPropertyRelative("match").stringValue + "_Large", overlayProp.objectReferenceValue as Texture2D);
|
|
130
|
+
|
|
131
|
+
previewSmallProp.objectReferenceValue = iconSmallProp.objectReferenceValue as Texture2D;
|
|
132
|
+
previewLargeProp.objectReferenceValue = iconLargeProp.objectReferenceValue as Texture2D;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Keep height in sync with elementHeightCallback
|
|
136
|
+
y += lineHeight + 4;
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
public override void OnInspectorGUI()
|
|
141
|
+
{
|
|
142
|
+
serializedObject.Update();
|
|
143
|
+
EditorGUILayout.PropertyField(serializedObject.FindProperty("showPreview"));
|
|
144
|
+
list.DoLayoutList();
|
|
145
|
+
serializedObject.ApplyModifiedProperties();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
using UnityEditor;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
using System.IO;
|
|
4
|
+
|
|
5
|
+
public static class FolderIconsSettingsMenu
|
|
6
|
+
{
|
|
7
|
+
[MenuItem("Tools/JaimeCamachoDev/UnityFolders/Crear configuraci�n")]
|
|
8
|
+
[MenuItem("Assets/JaimeCamachoDev/UnityFolders/Crear configuraci�n")]
|
|
9
|
+
public static void CreateAsset()
|
|
10
|
+
{
|
|
11
|
+
var asset = ScriptableObject.CreateInstance<FolderIconsSettings>();
|
|
12
|
+
string path = GetSelectedPathOrFallback();
|
|
13
|
+
string assetPath = AssetDatabase.GenerateUniqueAssetPath(Path.Combine(path, "FolderIconsSettings.asset"));
|
|
14
|
+
|
|
15
|
+
AssetDatabase.CreateAsset(asset, assetPath);
|
|
16
|
+
AssetDatabase.SaveAssets();
|
|
17
|
+
AssetDatabase.Refresh();
|
|
18
|
+
|
|
19
|
+
EditorUtility.FocusProjectWindow();
|
|
20
|
+
Selection.activeObject = asset;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
private static string GetSelectedPathOrFallback()
|
|
24
|
+
{
|
|
25
|
+
string path = "Assets";
|
|
26
|
+
foreach (Object obj in Selection.GetFiltered(typeof(Object), SelectionMode.Assets))
|
|
27
|
+
{
|
|
28
|
+
string selected = AssetDatabase.GetAssetPath(obj);
|
|
29
|
+
if (File.Exists(selected)) path = Path.GetDirectoryName(selected);
|
|
30
|
+
else if (Directory.Exists(selected)) path = selected;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
return path;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
using UnityEditor;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
using System.IO;
|
|
4
|
+
|
|
5
|
+
public static class UnityAssetsRenamer
|
|
6
|
+
{
|
|
7
|
+
[MenuItem("Tools/JaimeCamachoDev/UnityFolders/Renombrar Assets", false, 21)]
|
|
8
|
+
[MenuItem("Assets/JaimeCamachoDev/UnityFolders/Renombrar Assets", false, 21)]
|
|
9
|
+
private static void RenameAssetsMenu()
|
|
10
|
+
{
|
|
11
|
+
string folderPath = GetSelectedPathOrFallback();
|
|
12
|
+
|
|
13
|
+
if (!AssetDatabase.IsValidFolder(folderPath))
|
|
14
|
+
{
|
|
15
|
+
Debug.LogWarning("Por favor selecciona una carpeta válida para renombrar sus assets.");
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
RenameAssetsInFolder(folderPath);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
internal static void RenameAssetsInFolder(string folderPath)
|
|
23
|
+
{
|
|
24
|
+
string rootName = Path.GetFileName(folderPath);
|
|
25
|
+
string[] guids = AssetDatabase.FindAssets(string.Empty, new[] { folderPath });
|
|
26
|
+
|
|
27
|
+
foreach (string guid in guids)
|
|
28
|
+
{
|
|
29
|
+
string assetPath = AssetDatabase.GUIDToAssetPath(guid);
|
|
30
|
+
if (AssetDatabase.IsValidFolder(assetPath))
|
|
31
|
+
continue;
|
|
32
|
+
|
|
33
|
+
string directory = Path.GetDirectoryName(assetPath);
|
|
34
|
+
string extension = Path.GetExtension(assetPath);
|
|
35
|
+
string nameNoExt = Path.GetFileNameWithoutExtension(assetPath);
|
|
36
|
+
|
|
37
|
+
if (nameNoExt == rootName || nameNoExt.StartsWith(rootName + "_"))
|
|
38
|
+
continue;
|
|
39
|
+
|
|
40
|
+
int underscoreIndex = nameNoExt.IndexOf('_');
|
|
41
|
+
string suffix = underscoreIndex >= 0 ? nameNoExt.Substring(underscoreIndex + 1) : nameNoExt;
|
|
42
|
+
|
|
43
|
+
string newName = rootName + "_" + suffix;
|
|
44
|
+
string newPath = Path.Combine(directory, newName + extension);
|
|
45
|
+
newPath = AssetDatabase.GenerateUniqueAssetPath(newPath);
|
|
46
|
+
AssetDatabase.MoveAsset(assetPath, newPath);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
AssetDatabase.SaveAssets();
|
|
50
|
+
AssetDatabase.Refresh();
|
|
51
|
+
Debug.Log($"Assets en la carpeta {folderPath} han sido renombrados.");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private static string GetSelectedPathOrFallback()
|
|
55
|
+
{
|
|
56
|
+
string path = "Assets";
|
|
57
|
+
|
|
58
|
+
foreach (Object obj in Selection.GetFiltered(typeof(Object), SelectionMode.Assets))
|
|
59
|
+
{
|
|
60
|
+
path = AssetDatabase.GetAssetPath(obj);
|
|
61
|
+
if (!string.IsNullOrEmpty(path) && File.Exists(path))
|
|
62
|
+
{
|
|
63
|
+
path = Path.GetDirectoryName(path);
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return path;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|