• Unity Hierarchy 视图图标绘制


    using UnityEditor;
    using UnityEngine;
    
    [InitializeOnLoad]
    class UGUIOpenedPanelEditor
    {
        static readonly Texture2D TexturePanel;
        static UGUIOpenedPanelEditor()
        {
            TexturePanel =
                AssetDatabase.LoadAssetAtPath("Assets/Editor/UIEditorHelp/open.png", typeof(Texture2D)) as Texture2D;
            EditorApplication.hierarchyWindowItemOnGUI += CurrentOpenUIPanel;
        }
    
        static void CurrentOpenUIPanel(int instanceID, Rect selectionRect)
        {
            Rect r = new Rect(selectionRect);
            r.x = 0;
            r.width = 20;
            GameObject go = EditorUtility.InstanceIDToObject(instanceID) as GameObject;
            if (go != null)
            {
                //满足条件绘制Icon
                var canvasGroup = go.GetComponent<CanvasGroup>();
                if (canvasGroup != null && canvasGroup.alpha >= 1)
                {
                    GUI.Label(r, TexturePanel);
                }
            }
        }
    }
  • 相关阅读:
    hdoj 1002 A + B Problem II
    hdoj 1234 开门人和关门人
    hdoj 2203 亲和串
    nyoj 73 比大小
    81B
    信息传递
    bzoj1787
    最少交换次数
    100803C
    火柴排队
  • 原文地址:https://www.cnblogs.com/sanyejun/p/16534684.html
Copyright © 2020-2023  润新知