Exemplo n.º 1
0
        private bool TitleBarGUI()
        {
            GUILayout.BeginHorizontal(titleBarStyle);

            // Not a folder or not openned with context menu
            GUIContent warningContent = EditorGUIUtility.IconContent("console.warnicon.sml");

            if (selectionStatus == SelectionStatus.NONE)
            {
                warningContent.text = " No folder selected";
                EditorGUILayout.LabelField(warningContent);
                GUILayout.EndHorizontal();
                return(false);
            }

            if (selectionStatus == SelectionStatus.TOO_MANY)
            {
                warningContent.text = " Please select only one folder at a time.";
                EditorGUILayout.LabelField(warningContent);
                GUILayout.EndHorizontal();
                return(false);
            }

            string     folderName       = " " + Selection.GetFiltered <DefaultAsset>(SelectionMode.Assets)[0].name;
            GUIContent folderGuiContent = GUIHelper.ContentFromAssets(folderName, ResourceUtil.TexturesPath + "/folder_icon_16.png");

            // Get folder actual texture
            if (userData.Length > 0)
            {
                string[] guids = userData.Split(';');
                if (guids.Length == 2)
                {
                    Texture folderTexture = GUIHelper.LoadTexture(AssetDatabase.GUIDToAssetPath(guids[0]));
                    if (folderTexture != null)
                    {
                        folderGuiContent.image = folderTexture;
                    }
                }
            }

            GUILayout.Label(folderGuiContent);

            if (GUILayout.Button("Reset folder style", titleBarButtonStyle, GUILayout.Width(120.0F), GUILayout.ExpandWidth(false)))
            {
                ApplyStyle(null);
            }

            GUILayout.EndHorizontal();

            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Define window layout
        /// </summary>
        /// <param name="fI"></param>
        public void OnInspectorGUI(FolderInspector fI)
        {
            InitTextures();

            //// Header
            GUILayout.BeginHorizontal(FolderInspector.titleBarStyle);

            string     headerTitle      = (editStyle != null ? " Edit" : " New") + " style: ";
            GUIContent folderGuiContent = GUIHelper.ContentFromAssets(headerTitle, ResourceUtil.TexturesPath + "/folder_icon_16.png");

            GUILayout.Label(folderGuiContent);
            GUILayout.FlexibleSpace();

            // Name field
            GUILayout.BeginHorizontal();
            GUILayout.Label("Name:", FolderInspector.titleBarLabelStyle);
            string newStyleName = EditorGUILayout.TextField(styleName, FolderInspector.titleBarTextFieldStyle, GUILayout.ExpandWidth(false), GUILayout.Width(150.0f));

            if (!styleName.Equals(newStyleName))
            {
                styleName  = newStyleName;
                nameEdited = true;
            }

            GUILayout.EndHorizontal();
            EditorGUILayout.EndHorizontal();

            ColorGUI();


            // Icons
            IconGUI();

            GUILayout.Space(2);


            //// Preview
            // Real time change pixels

            if (PreferencesUI.settings.useNewUI)
            {
                UpdateTextureColor(folderOriginalTexture64, folderTexture64, -7, 2, 96, 80, 16, 24, 2.0F);
                UpdateTextureColor(folderOriginalTexture16, folderTexture16, 1, 3, 15, 13, 2, 3, 0.25F);

                Vector2Int offset = GetClampedBigIconOffset();
                UpdateTextureColor(folderOriginalIcon24, folderIcon24, 32 + offset.x - 3, 14 - offset.y + 1, 48, 40, 8, 16, 1.0F);

                offset = GetClampedSmallIconOffset();
                UpdateTextureColor(folderOriginalIcon10, folderIcon10, 6 + offset.x + 1, -offset.y + 3, 15, 13, 2, 3, 0.25F);
            }
            else
            {
                UpdateTextureColor(folderOriginalTexture64, folderTexture64, 3, 7, 56, 50, 3, 10, 1.0F);
                UpdateTextureColor(folderOriginalTexture16, folderTexture16, 2, 3, 15, 13, 0, 1, 0.25F);

                Vector2Int offset = GetClampedBigIconOffset();
                UpdateTextureColor(folderOriginalIcon24, folderIcon24, 32 + offset.x + 3, 14 - offset.y + 6, 56, 50, 4, 10, 1.0F);

                offset = GetClampedSmallIconOffset();
                UpdateTextureColor(folderOriginalIcon10, folderIcon10, 6 + offset.x + 2, -offset.y + 3, 15, 13, 0, 1, 0.25F);
            }

            GUILayout.BeginVertical();
            PreviewGUI();

            //// Button pannel
            ControlsGUI(fI);
            GUILayout.EndVertical();
        }