Ejemplo n.º 1
0
        private static void DrawTextures(Rect rect, FolderIconSettings.FolderIcon icon, Object folderAsset, string guid)
        {
            bool isTreeView = rect.width > rect.height;
            bool isSideView = FolderIconGUI.IsSideView(rect);

            // Vertical Folder View
            if (isTreeView)
            {
                rect.width = rect.height = FolderIconConstants.MAX_TREE_HEIGHT;

                //Add small offset for correct placement
                if (!isSideView)
                {
                    rect.x += 3f;
                }
            }
            else
            {
                rect.height -= 14f;
            }

            if (showFolder && icon.folderIcon)
            {
                FolderIconGUI.DrawFolderTexture(rect, icon.folderIcon, guid);
            }

            if (showOverlay && icon.overlayIcon)
            {
                FolderIconGUI.DrawOverlayTexture(rect, icon.overlayIcon);
            }
        }
Ejemplo n.º 2
0
        private void OnElementDraw(Rect rect, int index, bool isActive, bool isFocused)
        {
            SerializedProperty property = serializedIcons.GetArrayElementAtIndex(index);

            float fullWidth = rect.width;

            // Set sizes for correct draw
            float originalLabelWidth = EditorGUIUtility.labelWidth;
            float rectWidth          = MAX_LABEL_WIDTH + MAX_FIELD_WIDTH;

            EditorGUIUtility.labelWidth = Mathf.Min(EditorGUIUtility.labelWidth, MAX_LABEL_WIDTH);
            rect.width = Mathf.Min(rect.width, rectWidth);

            //Draw property and settings in a line
            DrawPropertyNoDepth(rect, property);

            // ==========================
            //     Draw Icon Example
            // ==========================
            rect.x    += rect.width;
            rect.width = fullWidth - rect.width;

            // References
            SerializedProperty folderTexture  = property.FindPropertyRelative("folderIcon");
            SerializedProperty overlayTexture = property.FindPropertyRelative("overlayIcon");
            SerializedProperty overlayOffset  = property.FindPropertyRelative("overlayOffset");

            // Object checks
            Object folderObject  = folderTexture.objectReferenceValue;
            Object overlayObject = overlayTexture.objectReferenceValue;

            FolderIconGUI.DrawFolderPreview(rect, folderObject as Texture, overlayObject as Texture);

            // Revert width modification
            EditorGUIUtility.labelWidth = originalLabelWidth;
        }