Unity修改Project下的Assets的子文件的图标

Unity修改文件夹的图标

示例:

在右键可以创建指定文件夹。

复制代码
github链接
https://github.com/SeaeeesSan/SimpleFolderIcon

CSDN资源的链接
https://download.csdn.net/download/GoodCooking/89347361
去GitHub下载支持原作者哦。

重要的事情

截图来自GitHub 。

  1. Unity版本是: Unity2019.4 or later
  2. 从GitHub上下载的只能是创建文件夹之后,自己修改名字然后会自动修改图标。修改的图标必须在SimpleFolderIcon/Icons下有对应的图片才会修改,没有对应的图片是不会修改的。
  3. 如果想添加更多风格的文件夹图标,在SimpleFolderIcon/Icons添加图片,然后将图片的名称改为需要修改图标的文件夹名称即可。
  4. 如果修改SimpleFolderIcon的位置,则需要修改IconDictionaryCreator.cs
csharp 复制代码
        private const string AssetsPath = "SimpleFolderIcon/Icons";

的路径。

  1. 自带的文件夹图标有:
java 复制代码
Animations
Audio
Editor
Fonts
Materials
Models
Plugins
Prefabs
Presets
Resources
Scenes
Scripts
Settings
Shaders
Sprites
Textures

我自己添加的:

java 复制代码
  StreamingAssets    Unity系统定义文件夹 
  ThirdPartyPlugins   第三方插件
  CertificateFolder     证书文件夹
  1. 在GIF中右键显示Folder_WithIcon需要添加编辑器脚本CreateCustomStyleFolder.cs
csharp 复制代码
using UnityEngine;
using UnityEditor;
using System.IO;

/// <summary>
/// 创建自定义风格的文件夹
/// </summary>
public class CreateCustomStyleFolder : MonoBehaviour
{
    [MenuItem("Assets/Create/Folder_WithIcon/Animations", false, 10)]
    private static void CreateAnimationsFolder()
    {
        CreateFolder("Animations");
    }

    [MenuItem("Assets/Create/Folder_WithIcon/Audio", false, 11)]
    private static void CreateAudioFolder()
    {
        CreateFolder("Audio");
    }

    [MenuItem("Assets/Create/Folder_WithIcon/Editor", false, 12)]
    private static void CreateEditorFolder()
    {
        CreateFolder("Editor");
    }

    [MenuItem("Assets/Create/Folder_WithIcon/Fonts", false, 13)]
    private static void CreateFontsFolder()
    {
        CreateFolder("Fonts");
    }

    [MenuItem("Assets/Create/Folder_WithIcon/Materials", false, 14)]
    private static void CreateMaterialsFolder()
    {
        CreateFolder("Materials");
    }

    [MenuItem("Assets/Create/Folder_WithIcon/Models", false, 15)]
    private static void CreateModelsFolder()
    {
        CreateFolder("Models");
    }

    [MenuItem("Assets/Create/Folder_WithIcon/Plugins", false, 16)]
    private static void CreatePluginsFolder()
    {
        CreateFolder("Plugins");
    }

    [MenuItem("Assets/Create/Folder_WithIcon/Prefabs", false, 17)]
    private static void CreatePrefabsFolder()
    {
        CreateFolder("Prefabs");
    }

    [MenuItem("Assets/Create/Folder_WithIcon/Presets", false, 18)]
    private static void CreatePresetsFolder()
    {
        CreateFolder("Presets");
    }

    [MenuItem("Assets/Create/Folder_WithIcon/Resources", false, 19)]
    private static void CreateResourcesFolder()
    {
        CreateFolder("Resources");
    }

    [MenuItem("Assets/Create/Folder_WithIcon/Scenes", false, 20)]
    private static void CreateScenesFolder()
    {
        CreateFolder("Scenes");
    }

    [MenuItem("Assets/Create/Folder_WithIcon/Scripts", false, 21)]
    private static void CreateScriptsFolder()
    {
        CreateFolder("Scripts");
    }

    [MenuItem("Assets/Create/Folder_WithIcon/Settings", false, 22)]
    private static void CreateSettingsFolder()
    {
        CreateFolder("Settings");
    }

    [MenuItem("Assets/Create/Folder_WithIcon/Shaders", false, 23)]
    private static void CreateShadersFolder()
    {
        CreateFolder("Shaders");
    }

    [MenuItem("Assets/Create/Folder_WithIcon/Sprites", false, 24)]
    private static void CreateSpritesFolder()
    {
        CreateFolder("Sprites");
    }

    [MenuItem("Assets/Create/Folder_WithIcon/Textures", false, 25)]
    private static void CreateTexturesFolder()
    {
        CreateFolder("Textures");
    }

    [MenuItem("Assets/Create/Folder_WithIcon/StreamingAssets", false, 26)]
    private static void CreateStreamingAssetsFolder()
    {
        CreateFolder("StreamingAssets");
    }

    [MenuItem("Assets/Create/Folder_WithIcon/ThirdPartyPlugins", false, 27)]
    private static void CreateThirdPartyPluginsFolder()
    {
        CreateFolder("ThirdPartyPlugins");
    }

    [MenuItem("Assets/Create/Folder_WithIcon/CertificateFolder", false, 28)]
    private static void CreateCertificateFolder()
    {
        CreateFolder("CertificateFolder");
    }


    private static void CreateFolder(string folderName)
    {
        // 获取鼠标右键点击的位置的路径
        string assetPath = AssetDatabase.GetAssetPath(Selection.activeObject);
        if (string.IsNullOrEmpty(assetPath))
        {
            assetPath = "Assets";
        }
        else if (Path.GetExtension(assetPath) != "")
        {
            assetPath = assetPath.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), "");
        }

        // 创建文件夹
        string newFolderPath = AssetDatabase.GenerateUniqueAssetPath(assetPath + "/" + folderName);
        AssetDatabase.CreateFolder(assetPath, folderName);
        AssetDatabase.Refresh();

        Debug.Log("Created folder at: " + newFolderPath);
    }
}
相关推荐
牙膏上的小苏打233314 小时前
Unity Surround开关后导致获取主显示器分辨率错误
unity·主屏幕
Unity大海16 小时前
诠视科技Unity SDK开发环境配置、项目设置、apk打包。
科技·unity·游戏引擎
浅陌sss1 天前
Unity中 粒子系统使用整理(一)
unity·游戏引擎
维度攻城狮1 天前
实现在Unity3D中仿真汽车,而且还能使用ros2控制
python·unity·docker·汽车·ros2·rviz2
为你写首诗ge1 天前
【Unity网络编程知识】FTP学习
网络·unity
神码编程1 天前
【Unity】 HTFramework框架(六十四)SaveDataRuntime运行时保存组件参数、预制体
unity·编辑器·游戏引擎
菲fay1 天前
Unity 单例模式写法
unity·单例模式
火一线1 天前
【Framework-Client系列】UIGenerate介绍
游戏·unity
ZKY_241 天前
【工具】Json在线解析工具
unity·json
ZKY_242 天前
【Unity】处理文字显示不全的问题
unity·游戏引擎