You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Unity:如何创建可折叠汉堡菜单图标自定义Inspector/Editor

Custom Inspector Icon Creation Guide

Hey there! Let’s tackle your question about that custom Inspector icon you saw in the video.

Is that icon creator-made?

Chances are, yes. Unity’s default Inspector doesn’t include custom stylized icons like the one you’re referencing—most creators either design their own from scratch or modify existing assets to match the Unity Editor’s aesthetic for their custom Editors.

Step-by-Step Guide to Create Your Own Custom Inspector Icon

1. Design the Icon

  • Size & Style: Stick to Unity’s standard icon dimensions (16x16, 24x24, or 32x32 pixels) to ensure it looks crisp across different Editor DPI settings. Aim for a flat, minimal style that matches Unity’s default iconography (avoid overly complex details).
  • Tools: Use design tools like Figma, Photoshop, Affinity Designer, or free alternatives such as Canva or Iconify. For pixel-perfect icons, Aseprite is a great choice.
  • Export: Save the icon as a PNG with a transparent background—this ensures it blends seamlessly with the Inspector’s UI.

2. Import & Configure the Icon in Unity

Drag your exported PNG into your Unity project, then select it and adjust these settings in the Inspector:

  • Texture Type: Set to Editor GUI and Legacy GUI
  • Sprite Mode: Choose Single
  • Filter Mode: Select Point (no filter) to prevent blurring
  • Max Size: Match the size you designed (e.g., 32)
  • Click Apply to save the changes.

3. Integrate the Icon into Your Custom Editor

Use Unity’s Editor scripting API to draw the icon in your custom Inspector. Here’s a quick example for a basic Editor class:

using UnityEditor;
using UnityEngine;

[CustomEditor(typeof(YourTargetScript))]
public class CustomScriptEditor : Editor
{
    private Texture2D _customIcon;

    private void OnEnable()
    {
        // Load your icon from the project path
        _customIcon = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Editor/Icons/YourCustomIcon.png");
    }

    public override void OnInspectorGUI()
    {
        // Draw the icon with adjusted size
        GUILayout.Label(_customIcon, GUILayout.Width(24), GUILayout.Height(24));
        
        // Draw your default or custom Inspector content below
        DrawDefaultInspector();
    }
}

If you’re using a PropertyDrawer, you can use similar logic in the OnGUI() method to place the icon alongside your property fields.

4. Alternative: Modify Unity’s Built-in Icons

If you don’t want to design from scratch, you can tweak Unity’s built-in Editor icons (found in your Unity installation directory under Editor/Data/Gizmos or Editor/Data/UnityEditor/Resources/Icon). Just make sure to check Unity’s license terms before modifying/reusing these for commercial projects.


内容的提问来源于stack exchange,提问作者Beks_Omega

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 04:00:11