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);
    }
}
相关推荐
神码编程3 小时前
【Unity功能集】TextureShop纹理工坊(五)选区
unity·游戏引擎·shader·ps选区
m0_748251728 小时前
Android webview 打开本地H5项目(Cocos游戏以及Unity游戏)
android·游戏·unity
benben0449 小时前
Unity3D仿星露谷物语开发7之事件创建动画
unity·游戏引擎
林枫依依11 小时前
Unity2021.3.16f1可以正常打开,但是Unity2017.3.0f3却常常打开闪退或者Unity2017编辑器运行起来就闪退掉
unity
虾球xz12 小时前
游戏引擎学习第57天
学习·游戏引擎
异次元的归来1 天前
Unity DOTS中的share component
unity·游戏引擎
向宇it1 天前
【从零开始入门unity游戏开发之——C#篇25】C#面向对象动态多态——virtual、override 和 base 关键字、抽象类和抽象方法
java·开发语言·unity·c#·游戏引擎
_oP_i1 天前
unity webgl部署到iis报错
unity
Go_Accepted1 天前
Unity全局雾效
unity
向宇it1 天前
【从零开始入门unity游戏开发之——C#篇24】C#面向对象继承——万物之父(object)、装箱和拆箱、sealed 密封类
java·开发语言·unity·c#·游戏引擎