コード例 #1
0
 public void ApplyStyle(StyleGrid.StyleElement style)
 {
     folderImporter.userData = style == null ? "" : AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(style.LowResTex)) + ";" + AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(style.HighResTex));
     folderImporter.SaveAndReimport();
     TryOpenSelection();
     CustomProjectView.RepaintProjectViews();
 }
コード例 #2
0
ファイル: PreferencesUI.cs プロジェクト: Valefors/Achromatic
        public static void PreferencesGUI()
        {
            // Load the preferences
            if (!preferencesLoaded)
            {
                folderIconEnabled  = EditorPrefs.GetBool("ext_" + ResourceUtil.ExtensionName + "_enabled", true);
                simpleClickEnabled = EditorPrefs.GetBool("ext_" + ResourceUtil.ExtensionName + "_simpleclick", false);
                preferencesLoaded  = true;
            }

            // Preferences GUI
            folderIconEnabled = EditorGUILayout.Toggle("Folder icons enabled", folderIconEnabled);
            GUI.enabled       = folderIconEnabled;
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUILayout.LabelField("Preferences: ", EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Show style selector on folder select");
            simpleClickEnabled = EditorGUILayout.Toggle(simpleClickEnabled);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
            GUI.enabled = true;

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUILayout.LabelField("Danger zone: ", EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Reset all folders"))
            {
                if (EditorUtility.DisplayDialog("Reset all folders?", "If you confirm all folders will use the default icon", "Yes", "No"))
                {
                    ResourceUtil.ClearAllFolders();
                }
            }
            if (GUILayout.Button("Delete all styles"))
            {
                if (EditorUtility.DisplayDialog("Delete all styles?", "If you confirm all custom styles will be deleted", "Yes", "No"))
                {
                    ResourceUtil.ClearAllFolders();
                    ResourceUtil.DeleteAllStyles();
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();

            // Save the preferences
            if (GUI.changed)
            {
                EditorPrefs.SetBool("ext_" + ResourceUtil.ExtensionName + "_enabled", folderIconEnabled);
                EditorPrefs.SetBool("ext_" + ResourceUtil.ExtensionName + "_simpleclick", simpleClickEnabled);
                CustomProjectView.RepaintProjectViews();
            }
        }
コード例 #3
0
ファイル: ResourceUtil.cs プロジェクト: dbooher/KC
        /// <summary>
        /// Reset all folders to their original state
        /// </summary>
        public static void ClearAllFolders()
        {
            // For each folder
            string[] files = AssetDatabase.FindAssets("t:defaultasset", new string[] { "Assets" });
            for (int i = 0; i < files.Length; i++)
            {
                string path = AssetDatabase.GUIDToAssetPath(files[i]);

                if (AssetDatabase.IsValidFolder(path))
                {
                    AssetImporter folderImporter = AssetImporter.GetAtPath(path);
                    string[]      guids          = folderImporter.userData.Split(';');
                    if (guids.Length == 2)
                    {
                        folderImporter.userData = "";
                        folderImporter.SaveAndReimport();
                    }
                }
            }

            CustomProjectView.RepaintProjectViews();
        }
コード例 #4
0
ファイル: PreferencesUI.cs プロジェクト: dbooher/KC
#pragma warning restore 0618
        public static void PreferencesGUI()
        {
            // Load the preferences
            if (!preferencesLoaded)
            {
                UpdatePreferences();
                preferencesLoaded = true;
            }

            // Preferences GUI
            folderIconEnabled = EditorGUILayout.Toggle("Folder icons enabled", folderIconEnabled);
            GUI.enabled       = folderIconEnabled;
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUILayout.LabelField("User Preferences: ", EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Show style selector on folder select");
            simpleClickEnabled = EditorGUILayout.Toggle(simpleClickEnabled);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUILayout.LabelField("Project Settings: ", EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Use Unity new icons");
            bool newUILocal = EditorGUILayout.Toggle(settings.useNewUI);

            if (settings.useNewUI != newUILocal)
            {
                settings.useNewUI = newUILocal;
                StyleConverter.ConvertStyles();
                settings.Write();
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUILayout.LabelField("Danger zone: ", EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Reset all folders"))
            {
                if (EditorUtility.DisplayDialog("Reset all folders?", "If you confirm all folders will use the default icon", "Yes", "No"))
                {
                    ResourceUtil.ClearAllFolders();
                }
            }
            if (GUILayout.Button("Delete all styles"))
            {
                if (EditorUtility.DisplayDialog("Delete all styles?", "If you confirm all custom styles will be deleted", "Yes", "No"))
                {
                    ResourceUtil.ClearAllFolders();
                    ResourceUtil.DeleteAllStyles();
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();

            GUI.enabled = true;

            // Save the preferences
            if (GUI.changed)
            {
                PreferenceHelper.SetBool("enabled", folderIconEnabled);
                PreferenceHelper.SetBool("simpleclick", simpleClickEnabled);
                CustomProjectView.RepaintProjectViews();
            }
        }