本文主要是介绍Unity修改Project下的Assets的子文件的图标,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Unity修改文件夹的图标
示例:
在右键可以创建指定文件夹。
github链接
https://github.com/SeaeeesSan/SimpleFolderIconCSDN资源的链接
https://download.csdn.net/download/GoodCooking/89347361
去GitHub下载支持原作者哦。
重要的事情
截图来自GitHub 。
- Unity版本是: Unity2019.4 or later
- 从GitHub上下载的只能是创建文件夹之后,自己修改名字然后会自动修改图标。修改的图标必须在SimpleFolderIcon/Icons下有对应的图片才会修改,没有对应的图片是不会修改的。
- 如果想添加更多风格的文件夹图标,在SimpleFolderIcon/Icons添加图片,然后将图片的名称改为需要修改图标的文件夹名称即可。
- 如果修改SimpleFolderIcon的位置,则需要修改
IconDictionaryCreator.cs
中
private const string AssetsPath = "SimpleFolderIcon/Icons";
的路径。
- 自带的文件夹图标有:
Animations
Audio
Editor
Fonts
Materials
Models
Plugins
Prefabs
Presets
Resources
Scenes
Scripts
Settings
Shaders
Sprites
Textures
我自己添加的:
StreamingAssets Unity系统定义文件夹 ThirdPartyPlugins 第三方插件CertificateFolder 证书文件夹
- 在GIF中右键显示
Folder_WithIcon
需要添加编辑器脚本CreateCustomStyleFolder.cs
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);}
}
这篇关于Unity修改Project下的Assets的子文件的图标的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!