private static void DrawCustomIcon(string guid, Rect rect, Texture texture, bool isSmall)
        {
            if (rect.width > LARGE_ICON_SIZE)
            {
                // center the icon if it is zoomed
                var offset = (rect.width - LARGE_ICON_SIZE) / 2f;
                rect = new Rect(rect.x + offset, rect.y + offset, LARGE_ICON_SIZE, LARGE_ICON_SIZE);
            }
            else
            {
                // unity shifted small icons a bit in 5.5
#if UNITY_5_5
                if (isSmall)
                {
                    rect = new Rect(rect.x + 3, rect.y, rect.width, rect.height);
                }
#elif UNITY_5_6_OR_NEWER
                if (isSmall && !IsTreeView(rect))
                {
                    rect = new Rect(rect.x + 3, rect.y, rect.width, rect.height);
                }
#endif
            }

            if (_isCollabEnabled())
            {
                var background = RainbowFoldersEditorUtility.GetCollabBackground(isSmall, EditorGUIUtility.isProSkin);
                GUI.DrawTexture(rect, background);
                GUI.DrawTexture(rect, texture);

#if UNITY_2020_1_OR_NEWER
                _drawCollabOverlay(guid, rect, null);
#else
                _drawCollabOverlay(guid, rect);
#endif
            }
            else if (_isVcsEnabled())
            {
                var iconRect = (!isSmall) ? rect : new Rect(rect.x + 7, rect.y, rect.width, rect.height);
                GUI.DrawTexture(iconRect, texture);
#if UNITY_2020_1_OR_NEWER
                _drawCollabOverlay(guid, rect, null);
#else
                _drawCollabOverlay(guid, rect);
#endif
            }
            else
            {
                GUI.DrawTexture(rect, texture);
            }
        }
Exemplo n.º 2
0
        private static void DrawCustomIcon(string guid, Rect rect, Texture texture, bool isSmall)
        {
            var iconRect = rect;

            if (iconRect.width > LARGE_ICON_SIZE)
            {
                // center the icon if it is zoomed
                var offset = (iconRect.width - LARGE_ICON_SIZE) / 2f;
                iconRect = new Rect(iconRect.x + offset, iconRect.y + offset, LARGE_ICON_SIZE, LARGE_ICON_SIZE);
            }
            else
            {
                // unity shifted small icons a bit in 5.5
                #if UNITY_5_5
                if (isSmall)
                {
                    rect = iconRect = new Rect(iconRect.x + 3, iconRect.y, iconRect.width, iconRect.height);
                }
                #endif
            }

            if (_isCollabEnabled())
            {
                var background = RainbowFoldersEditorUtility.GetCollabBackground(isSmall, EditorGUIUtility.isProSkin);

                GUI.Box(rect, string.Empty, ItemBgStyle);
                GUI.DrawTexture(iconRect, background);
                GUI.DrawTexture(iconRect, texture);

                #if UNITY_2017_1_OR_NEWER
                _drawCollabOverlay(rect, guid, isSmall);
                #else
                _drawCollabOverlay(guid, rect);
                #endif
            }
            else if (_isVcsEnabled())
            {
                var background = RainbowFoldersEditorUtility.GetCollabBackground(isSmall, EditorGUIUtility.isProSkin);
                iconRect = (!isSmall) ? iconRect : new Rect(iconRect.x + 7, iconRect.y, iconRect.width, iconRect.height);

                GUI.Box(rect, string.Empty, ItemBgStyle);
                GUI.DrawTexture(iconRect, background);
                GUI.DrawTexture(iconRect, texture);
                _drawVcsOverlay(guid, rect, null);
            }
            else
            {
                GUI.DrawTexture(iconRect, texture);
            }
        }