Пример #1
0
 public AssetObjectInfo(string path, SerializableSystemType type)
 {
     this.m_Path = path;
     string[] parts = path.Split('/');
     this.m_Name = parts[parts.Length - 1];
     this.m_Type = type;
 }
Пример #2
0
    public override bool Equals(System.Object obj)
    {
        SerializableSystemType temp = obj as SerializableSystemType;

        if ((object)temp == null)
        {
            return(false);
        }
        return(this.Equals(temp));
    }
Пример #3
0
 public AssetObjectInfo(string path, SerializableSystemType type)
 {
     this.m_Path = path;
     string[] parts = path.Split('/');
     this.m_Name = parts[parts.Length - 1];
     this.m_Type = type;
     System.IO.FileInfo fileInfo = new System.IO.FileInfo(path);
     this.m_FileSize = fileInfo.Length;
     this.m_FileSizeString = AssetHunterHelper.BytesToString(m_FileSize);
 }
Пример #4
0
    /// <summary>
    /// Updates the ContainedTypesString to fit all the contained types
    /// </summary>
    void MakeTypeList()
    {
        // Debug.Log("remaking Type list");
        targetTable.typeList.Clear();
        //containedTypeString = "Contained Types: ";
        int typeCount = targetTable.containedTypes.Count;

        for (int i = 0; i < typeCount; i++)
        {
            SerializableSystemType t = targetTable.containedTypes[i];

            targetTable.typeList.Add(new TypeToggle(t));
        }
    }
Пример #5
0
        public override bool Equals(object obj)
        {
            TypeToggle             otherToggle = obj as TypeToggle;
            SerializableSystemType t           = null;

            if (otherToggle == null)
            {
                t = obj as SerializableSystemType;
            }
            else
            {
                t = otherToggle.type;
            }

            return(t == type);
        }
Пример #6
0
        public bool ContainsType(SerializableSystemType t)
        {
            SerializableSystemType st = null;

            for (int i = 0; i < containedTypes.Count; i++)
            {
                st = containedTypes[i];
                if (st == null)
                {
                    continue;
                }
                //Debug.Log("Checking if " + st.SystemType + " is the same as " + t.SystemType + " on " + this.name, this);
                if (st.SystemType == t.SystemType)
                {
                    //Debug.Log("IT IS!!!!", this);
                    return(true);
                }
            }

            //Debug.Log("ITS NOT!!!!", this);
            return(false);
        }
Пример #7
0
 public bool Equals(SerializableSystemType _Object)
 {
     //return m_AssemblyQualifiedName.Equals(_Object.m_AssemblyQualifiedName);
     return(_Object.SystemType == SystemType);
 }
    private void OnGUI()
    {

        if (settings == null)
        {
            string path = AssetHunterSettingsCreator.GetAssetPath();
            settings = AssetDatabase.LoadAssetAtPath(path, typeof(ScriptableObject)) as AssetHunterSettings;
        }

        scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

        //Show all used types
        EditorGUILayout.BeginVertical();
        string selectedPath = AssetDatabase.GetAssetPath(Selection.activeObject);

        //Make sure this window has focus to update contents
        AssetHunterSettingsWindow.Instance.Repaint();

        EditorGUILayout.Separator();
        GUILayout.Label("This is the settingswindow for Asset Hunter! " + System.Environment.NewLine + "-Choose folders and types to exclude when scanning the project");
        EditorGUILayout.Separator();
        EditorGUILayout.Separator();

        //Do we have a folder selected
        bool bFolderSelected = System.IO.Directory.Exists(selectedPath);
        //Is it valid
        bool validSelection = (bFolderSelected && settings.ValidateDirectory(Selection.activeObject));

        //Select folder to exclude
        EditorGUILayout.BeginHorizontal();

        GUI.color = (validSelection ? Color.green : Color.grey);

        if (GUILayout.Button(validSelection ? "Exclude selected folder" : "No valid folder selected", GUILayout.Width(btnMinWidthLarge)))
        {
            if (validSelection)
            {
                settings.ExcludeDirectory(Selection.activeObject);
            }
        }

        GUI.color = m_IntialGUIColor;

        if (validSelection)
            GUILayout.Label(selectedPath, EditorStyles.miniBoldLabel);

        GUI.color = m_IntialGUIColor;
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Separator();

        //Select type to exclude
        EditorGUILayout.BeginHorizontal();
        SerializableSystemType selectedType = null;

        if (Selection.activeObject)
            selectedType = new SerializableSystemType(Selection.activeObject.GetType());

        //Do we have a valid asset selected
        validSelection = (selectedType != null && !bFolderSelected && settings.ValidateType(selectedType));

        GUI.color = (validSelection ? Color.green : Color.grey);

        if (GUILayout.Button(validSelection ? "Exclude selected type" : "No valid type selected", GUILayout.Width(btnMinWidthLarge)))
        {
            if (validSelection)
            {
                settings.ExcludeType(selectedType);
            }
        }

        if (validSelection)
            GUILayout.Label(selectedType.SystemType.ToString(), EditorStyles.miniBoldLabel);

        GUI.color = m_IntialGUIColor;

        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Separator();
        EditorGUILayout.Separator();

        GUILayout.Label("---------------------------Excluded Folders------------------------------", EditorStyles.boldLabel);

        if (settings.m_DirectoryExcludes.Count >= 1)
            for (int i = settings.m_DirectoryExcludes.Count - 1; i >= 0; i--)
            {
                EditorGUILayout.BeginHorizontal();
                GUI.color = Color.red;

                if (GUILayout.Button("Delete", GUILayout.Width(btnMinWidthSmall)))
                {
                    settings.RemoveDirectoryAtIndex(i);
                    continue;
                }
                GUI.color = m_IntialGUIColor;
                EditorGUILayout.ObjectField(settings.m_DirectoryExcludes[i], typeof(UnityEngine.Object), false);
                EditorGUILayout.EndHorizontal();
            }
        else
        {
            EditorGUILayout.LabelField("No folders are currently excluded");
        }

        EditorGUILayout.Separator();
        GUILayout.Label("---------------------------Excluded Types--------------------------------", EditorStyles.boldLabel);

        if (settings.m_AssetTypeExcludes.Count >= 1)
            for (int i = settings.m_AssetTypeExcludes.Count - 1; i >= 0; i--)
            {
                EditorGUILayout.BeginHorizontal();
                GUI.color = Color.red;
                if (GUILayout.Button("Delete", GUILayout.Width(btnMinWidthSmall)))
                {
                    settings.RemoveTypeAtIndex(i);
                    continue;
                }
                GUI.color = m_IntialGUIColor;
                GUILayout.Label(settings.m_AssetTypeExcludes[i].Name);
                EditorGUILayout.EndHorizontal();
            }
        else
        {
            EditorGUILayout.LabelField("No types are currently excluded");
        }

        EditorGUILayout.EndVertical();
        EditorGUILayout.EndScrollView();
    }
Пример #9
0
 internal void ExcludeType(SerializableSystemType newtype)
 {
     m_AssetTypeExcludes.Add(newtype);
 }
Пример #10
0
 internal bool ValidateType(SerializableSystemType newtype)
 {
     return !m_AssetTypeExcludes.Contains(newtype);
 }
    private void OnGUI()
    {
        if (settings == null)
        {
            string path = AssetHunterSettingsCreator.GetAssetPath();
            settings = AssetDatabase.LoadAssetAtPath(path, typeof(ScriptableObject)) as AssetHunterSettings;
        }

        scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

        //Show all used types
        EditorGUILayout.BeginVertical();
        string selectedPath = AssetDatabase.GetAssetPath(Selection.activeObject);

        //Make sure this window has focus to update contents
        AssetHunterSettingsWindow.Instance.Repaint();

        EditorGUILayout.Separator();
        GUILayout.Label("This is the settingswindow for Asset Hunter! " + System.Environment.NewLine + "-Choose folders, types or filenames to exclude when scanning the project", EditorStyles.boldLabel);
        GUILayout.Label("NB: If your project window is in \"Two column layout\" you need to select folders in the right hand side of that window", EditorStyles.miniLabel);

        GUILayout.Label("----------------------------------------------------------------------------", EditorStyles.boldLabel);
        //Force memorycleanup
        settings.m_MemoryCleanupActive = GUILayout.Toggle(settings.m_MemoryCleanupActive, "Force memory cleanup");
        GUILayout.Label("Enable this if you experience memory crashes (Much slower)", EditorStyles.miniLabel);
        GUILayout.Label("----------------------------------------------------------------------------", EditorStyles.boldLabel);

        EditorGUILayout.Separator();
        EditorGUILayout.Separator();

        //Do we have a folder selected
        bool bFolderSelected = System.IO.Directory.Exists(selectedPath);
        //Is it valid
        bool validSelection = (bFolderSelected && settings.ValidateDirectory(Selection.activeObject));

        //Select folder to exclude
        EditorGUILayout.BeginHorizontal();

        GUI.color = (validSelection ? AssetHunterHelper.AH_BLUE : AssetHunterHelper.AH_GREY);

        if (GUILayout.Button(validSelection ? "Exclude selected folder" : "No valid folder selected", GUILayout.Width(btnMinWidthLarge)))
        {
            if (validSelection)
            {
                settings.ExcludeDirectory(Selection.activeObject);
            }
        }

        GUI.color = m_IntialGUIColor;

        if (validSelection)
            GUILayout.Label(selectedPath, EditorStyles.miniBoldLabel);

        GUI.color = m_IntialGUIColor;
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Separator();

        //Select type to exclude
        EditorGUILayout.BeginHorizontal();
        SerializableSystemType selectedType = null;

        if (Selection.activeObject)
            selectedType = new SerializableSystemType(Selection.activeObject.GetType());

        //Do we have a valid asset selected
        validSelection = (selectedType != null && !bFolderSelected && settings.ValidateType(selectedType));

        GUI.color = (validSelection ? AssetHunterHelper.AH_BLUE : AssetHunterHelper.AH_GREY);

        if (GUILayout.Button(validSelection ? "Exclude selected type" : "No valid type selected", GUILayout.Width(btnMinWidthLarge)))
        {
            if (validSelection)
            {
                settings.ExcludeType(selectedType);
            }
        }

        if (validSelection)
            GUILayout.Label(selectedType.SystemType.ToString(), EditorStyles.miniBoldLabel);

        GUI.color = m_IntialGUIColor;

        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Separator();

        //Exluded filename substrings
        EditorGUILayout.BeginHorizontal();

        validSelection = !string.IsNullOrEmpty(m_excludeSubstringInput) && settings.ValidateSubstring(m_excludeSubstringInput);
        GUI.color = (validSelection ? AssetHunterHelper.AH_BLUE : AssetHunterHelper.AH_GREY);

        bool bHasHitEnter = false;

        Event e = Event.current;
        if (e.keyCode == KeyCode.Return) bHasHitEnter = true;

        if (bHasHitEnter || GUILayout.Button(validSelection ? "Exclude substring": "No valid search string", GUILayout.Width(btnMinWidthLarge)))
        {
            if (validSelection)
            {
                settings.ExcludeSubstring(m_excludeSubstringInput);
                m_excludeSubstringInput = string.Empty;
            }
        }

        GUI.color = m_IntialGUIColor;
        m_excludeSubstringInput = GUILayout.TextField(m_excludeSubstringInput);

        //GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        if (validSelection)
            GUILayout.Label(string.Format("Will exclude any asset with \"{0}\" in its path/name (might make asset hunter perform slower)", m_excludeSubstringInput));

        EditorGUILayout.Separator();
        EditorGUILayout.Separator();

        GUILayout.Label("---------------------------Excluded Folders------------------------------", EditorStyles.boldLabel);

        if (settings.m_DirectoryExcludes.Count >= 1)
            for (int i = settings.m_DirectoryExcludes.Count - 1; i >= 0; i--)
            {
                EditorGUILayout.BeginHorizontal();
                GUI.color = AssetHunterHelper.AH_RED;

                if (GUILayout.Button("Delete", GUILayout.Width(btnMinWidthSmall)))
                {
                    settings.RemoveDirectoryAtIndex(i);
                    continue;
                }
                GUI.color = m_IntialGUIColor;
                EditorGUILayout.ObjectField(settings.m_DirectoryExcludes[i], typeof(UnityEngine.Object), false);
                EditorGUILayout.EndHorizontal();
            }
        else
        {
            EditorGUILayout.LabelField("No folders are currently excluded");
        }

        EditorGUILayout.Separator();
        GUILayout.Label("---------------------------Excluded Types--------------------------------", EditorStyles.boldLabel);

        if (settings.m_AssetTypeExcludes.Count >= 1)
            for (int i = settings.m_AssetTypeExcludes.Count - 1; i >= 0; i--)
            {
                EditorGUILayout.BeginHorizontal();
                GUI.color = AssetHunterHelper.AH_RED;
                if (GUILayout.Button("Delete", GUILayout.Width(btnMinWidthSmall)))
                {
                    settings.RemoveTypeAtIndex(i);
                    continue;
                }
                GUI.color = m_IntialGUIColor;
                GUILayout.Label(settings.m_AssetTypeExcludes[i].Name);
                EditorGUILayout.EndHorizontal();
            }
        else
        {
            EditorGUILayout.LabelField("No types are currently excluded");
        }

        EditorGUILayout.Separator();

        GUILayout.Label("---------------------------Excluded Substrings---------------------------", EditorStyles.boldLabel);
        if (settings.m_AssetSubstringExcludes.Count >= 1)
            for (int i = settings.m_AssetSubstringExcludes.Count - 1; i >= 0; i--)
            {
                EditorGUILayout.BeginHorizontal();
                GUI.color = AssetHunterHelper.AH_RED;
                if (GUILayout.Button("Delete", GUILayout.Width(btnMinWidthSmall)))
                {
                    settings.RemoveSubstringAtIndex(i);
                    continue;
                }
                GUI.color = m_IntialGUIColor;
                GUILayout.Label(string.Format("\"{0}\"", settings.m_AssetSubstringExcludes[i]));
                EditorGUILayout.EndHorizontal();
            }
        else
        {
            EditorGUILayout.LabelField("No substrings are currently excluded");
        }

        EditorGUILayout.EndVertical();
        EditorGUILayout.EndScrollView();
    }
Пример #12
0
    private void OnGUI()
    {
        if (settings == null)
        {
            string path = AssetHunterSettingsCreator.GetAssetPath();
            settings = AssetDatabase.LoadAssetAtPath(path, typeof(ScriptableObject)) as AssetHunterSettings;
        }

        scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

        //Show all used types
        EditorGUILayout.BeginVertical();
        string selectedPath = AssetDatabase.GetAssetPath(Selection.activeObject);

        //Make sure this window has focus to update contents
        AssetHunterSettingsWindow.Instance.Repaint();

        EditorGUILayout.Separator();
        GUILayout.Label("This is the settingswindow for Asset Hunter! " + System.Environment.NewLine + "-Choose folders, types or filenames to exclude when scanning the project", EditorStyles.boldLabel);
        GUILayout.Label("NB: If your project window is in \"Two column layout\" you need to select folders in the right hand side of that window", EditorStyles.miniLabel);

        GUILayout.Label("----------------------------------------------------------------------------", EditorStyles.boldLabel);
        //Force memorycleanup
        settings.m_MemoryCleanupActive = GUILayout.Toggle(settings.m_MemoryCleanupActive, "Force memory cleanup");
        GUILayout.Label("Enable this if you experience memory crashes (Much slower)", EditorStyles.miniLabel);
        GUILayout.Label("----------------------------------------------------------------------------", EditorStyles.boldLabel);

        EditorGUILayout.Separator();
        EditorGUILayout.Separator();

        //Do we have a folder selected
        bool bFolderSelected = System.IO.Directory.Exists(selectedPath);
        //Is it valid
        bool validSelection = (bFolderSelected && settings.ValidateDirectory(Selection.activeObject));

        //Select folder to exclude
        EditorGUILayout.BeginHorizontal();

        GUI.color = (validSelection ? AssetHunterHelper.AH_BLUE : AssetHunterHelper.AH_GREY);

        if (GUILayout.Button(validSelection ? "Exclude selected folder" : "No valid folder selected", GUILayout.Width(btnMinWidthLarge)))
        {
            if (validSelection)
            {
                settings.ExcludeDirectory(Selection.activeObject);
            }
        }

        GUI.color = m_IntialGUIColor;

        if (validSelection)
        {
            GUILayout.Label(selectedPath, EditorStyles.miniBoldLabel);
        }

        GUI.color = m_IntialGUIColor;
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Separator();

        //Select type to exclude
        EditorGUILayout.BeginHorizontal();
        SerializableSystemType selectedType = null;

        if (Selection.activeObject)
        {
            selectedType = new SerializableSystemType(Selection.activeObject.GetType());
        }

        //Do we have a valid asset selected
        validSelection = (selectedType != null && !bFolderSelected && settings.ValidateType(selectedType));

        GUI.color = (validSelection ? AssetHunterHelper.AH_BLUE : AssetHunterHelper.AH_GREY);

        if (GUILayout.Button(validSelection ? "Exclude selected type" : "No valid type selected", GUILayout.Width(btnMinWidthLarge)))
        {
            if (validSelection)
            {
                settings.ExcludeType(selectedType);
            }
        }

        if (validSelection)
        {
            GUILayout.Label(selectedType.SystemType.ToString(), EditorStyles.miniBoldLabel);
        }

        GUI.color = m_IntialGUIColor;

        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Separator();

        //Exluded filename substrings
        EditorGUILayout.BeginHorizontal();

        validSelection = !string.IsNullOrEmpty(m_excludeSubstringInput) && settings.ValidateSubstring(m_excludeSubstringInput);
        GUI.color      = (validSelection ? AssetHunterHelper.AH_BLUE : AssetHunterHelper.AH_GREY);

        bool bHasHitEnter = false;

        Event e = Event.current;

        if (e.keyCode == KeyCode.Return)
        {
            bHasHitEnter = true;
        }

        if (bHasHitEnter || GUILayout.Button(validSelection ? "Exclude substring": "No valid search string", GUILayout.Width(btnMinWidthLarge)))
        {
            if (validSelection)
            {
                settings.ExcludeSubstring(m_excludeSubstringInput);
                m_excludeSubstringInput = string.Empty;
            }
        }

        GUI.color = m_IntialGUIColor;
        m_excludeSubstringInput = GUILayout.TextField(m_excludeSubstringInput);

        //GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        if (validSelection)
        {
            GUILayout.Label(string.Format("Will exclude any asset with \"{0}\" in its path/name (might make asset hunter perform slower)", m_excludeSubstringInput));
        }

        EditorGUILayout.Separator();
        EditorGUILayout.Separator();

        GUILayout.Label("---------------------------Excluded Folders------------------------------", EditorStyles.boldLabel);

        if (settings.m_DirectoryExcludes.Count >= 1)
        {
            for (int i = settings.m_DirectoryExcludes.Count - 1; i >= 0; i--)
            {
                EditorGUILayout.BeginHorizontal();
                GUI.color = AssetHunterHelper.AH_RED;

                if (GUILayout.Button("Delete", GUILayout.Width(btnMinWidthSmall)))
                {
                    settings.RemoveDirectoryAtIndex(i);
                    continue;
                }
                GUI.color = m_IntialGUIColor;
                EditorGUILayout.ObjectField(settings.m_DirectoryExcludes[i], typeof(UnityEngine.Object), false);
                EditorGUILayout.EndHorizontal();
            }
        }
        else
        {
            EditorGUILayout.LabelField("No folders are currently excluded");
        }

        EditorGUILayout.Separator();
        GUILayout.Label("---------------------------Excluded Types--------------------------------", EditorStyles.boldLabel);

        if (settings.m_AssetTypeExcludes.Count >= 1)
        {
            for (int i = settings.m_AssetTypeExcludes.Count - 1; i >= 0; i--)
            {
                EditorGUILayout.BeginHorizontal();
                GUI.color = AssetHunterHelper.AH_RED;
                if (GUILayout.Button("Delete", GUILayout.Width(btnMinWidthSmall)))
                {
                    settings.RemoveTypeAtIndex(i);
                    continue;
                }
                GUI.color = m_IntialGUIColor;
                GUILayout.Label(settings.m_AssetTypeExcludes[i].Name);
                EditorGUILayout.EndHorizontal();
            }
        }
        else
        {
            EditorGUILayout.LabelField("No types are currently excluded");
        }

        EditorGUILayout.Separator();

        GUILayout.Label("---------------------------Excluded Substrings---------------------------", EditorStyles.boldLabel);
        if (settings.m_AssetSubstringExcludes.Count >= 1)
        {
            for (int i = settings.m_AssetSubstringExcludes.Count - 1; i >= 0; i--)
            {
                EditorGUILayout.BeginHorizontal();
                GUI.color = AssetHunterHelper.AH_RED;
                if (GUILayout.Button("Delete", GUILayout.Width(btnMinWidthSmall)))
                {
                    settings.RemoveSubstringAtIndex(i);
                    continue;
                }
                GUI.color = m_IntialGUIColor;
                GUILayout.Label(string.Format("\"{0}\"", settings.m_AssetSubstringExcludes[i]));
                EditorGUILayout.EndHorizontal();
            }
        }
        else
        {
            EditorGUILayout.LabelField("No substrings are currently excluded");
        }

        EditorGUILayout.EndVertical();
        EditorGUILayout.EndScrollView();
    }
    private void OnGUI()
    {
        if (settings == null)
        {
            string path = AssetHunterSettingsCreator.GetAssetPath();
            settings = AssetDatabase.LoadAssetAtPath(path, typeof(ScriptableObject)) as AssetHunterSettings;
        }

        scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

        //Show all used types
        EditorGUILayout.BeginVertical();
        string selectedPath = AssetDatabase.GetAssetPath(Selection.activeObject);

        //Make sure this window has focus to update contents
        AssetHunterSettingsWindow.Instance.Repaint();

        EditorGUILayout.Separator();
        GUILayout.Label("This is the settingswindow for Asset Hunter! " + System.Environment.NewLine + "-Choose folders and types to exclude when scanning the project");
        EditorGUILayout.Separator();
        EditorGUILayout.Separator();

        //Do we have a folder selected
        bool bFolderSelected = System.IO.Directory.Exists(selectedPath);
        //Is it valid
        bool validSelection = (bFolderSelected && settings.ValidateDirectory(Selection.activeObject));

        //Select folder to exclude
        EditorGUILayout.BeginHorizontal();

        GUI.color = (validSelection ? Color.green : Color.grey);

        if (GUILayout.Button(validSelection ? "Exclude selected folder" : "No valid folder selected", GUILayout.Width(btnMinWidthLarge)))
        {
            if (validSelection)
            {
                settings.ExcludeDirectory(Selection.activeObject);
            }
        }

        GUI.color = m_IntialGUIColor;

        if (validSelection)
        {
            GUILayout.Label(selectedPath, EditorStyles.miniBoldLabel);
        }

        GUI.color = m_IntialGUIColor;
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Separator();

        //Select type to exclude
        EditorGUILayout.BeginHorizontal();
        SerializableSystemType selectedType = null;

        if (Selection.activeObject)
        {
            selectedType = new SerializableSystemType(Selection.activeObject.GetType());
        }

        //Do we have a valid asset selected
        validSelection = (selectedType != null && !bFolderSelected && settings.ValidateType(selectedType));

        GUI.color = (validSelection ? Color.green : Color.grey);

        if (GUILayout.Button(validSelection ? "Exclude selected type" : "No valid type selected", GUILayout.Width(btnMinWidthLarge)))
        {
            if (validSelection)
            {
                settings.ExcludeType(selectedType);
            }
        }

        if (validSelection)
        {
            GUILayout.Label(selectedType.SystemType.ToString(), EditorStyles.miniBoldLabel);
        }

        GUI.color = m_IntialGUIColor;

        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Separator();
        EditorGUILayout.Separator();

        GUILayout.Label("---------------------------Excluded Folders------------------------------", EditorStyles.boldLabel);

        if (settings.m_DirectoryExcludes.Count >= 1)
        {
            for (int i = settings.m_DirectoryExcludes.Count - 1; i >= 0; i--)
            {
                EditorGUILayout.BeginHorizontal();
                GUI.color = Color.red;

                if (GUILayout.Button("Delete", GUILayout.Width(btnMinWidthSmall)))
                {
                    settings.RemoveDirectoryAtIndex(i);
                    continue;
                }
                GUI.color = m_IntialGUIColor;
                EditorGUILayout.ObjectField(settings.m_DirectoryExcludes[i], typeof(UnityEngine.Object), false);
                EditorGUILayout.EndHorizontal();
            }
        }
        else
        {
            EditorGUILayout.LabelField("No folders are currently excluded");
        }

        EditorGUILayout.Separator();
        GUILayout.Label("---------------------------Excluded Types--------------------------------", EditorStyles.boldLabel);

        if (settings.m_AssetTypeExcludes.Count >= 1)
        {
            for (int i = settings.m_AssetTypeExcludes.Count - 1; i >= 0; i--)
            {
                EditorGUILayout.BeginHorizontal();
                GUI.color = Color.red;
                if (GUILayout.Button("Delete", GUILayout.Width(btnMinWidthSmall)))
                {
                    settings.RemoveTypeAtIndex(i);
                    continue;
                }
                GUI.color = m_IntialGUIColor;
                GUILayout.Label(settings.m_AssetTypeExcludes[i].Name);
                EditorGUILayout.EndHorizontal();
            }
        }
        else
        {
            EditorGUILayout.LabelField("No types are currently excluded");
        }

        EditorGUILayout.EndVertical();
        EditorGUILayout.EndScrollView();
    }
Пример #14
0
 public TypeToggle(SerializableSystemType t)
 {
     toggled = false;
     type    = t;
 }
Пример #15
0
        private static void traverseDirectory(int parentIndex, string path, List<BuildReportAsset> usedAssets, int heirarchyDepth, ref int directoriesTraversed, SortedDictionary<SerializableSystemType, bool> validTypeList)
        {
            directoriesTraversed++;

            EditorUtility.DisplayProgressBar(
                                "Traversing Directories",
                                "(" + directoriesTraversed + " of " + m_NumberOfDirectories + ") Analyzing " + path.Substring(path.IndexOf("/Assets") + 1),
                                (float)directoriesTraversed / (float)m_NumberOfDirectories);

            //Get the settings to exclude vertain folders or suffixes
            foreach (UnityEngine.Object dir in AssetHunterMainWindow.Instance.settings.m_DirectoryExcludes)
            {
                //TODO Can this be done more elegantly
                int startingIndex = Application.dataPath.Length - 6;
                string relativePath = path.Substring(startingIndex, path.Length - startingIndex);
                UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(relativePath, typeof(UnityEngine.Object));

                if (dir == obj)
                {
                    //This folder was exluded
                    return;
                }
            }

            //Exclude types and folders that should not be reviewed
            //TODO perhaps improve performance of this step (Also use String.Contains(excluder, StringComparison.OrdinalIgnoreCase)) might be better not to use LINQ
            string[] assetsInDirectory = Directory.GetFiles(path, "*.*", SearchOption.TopDirectoryOnly)
                .Where(name => !name.ToLowerInvariant().EndsWith(".meta")
                    && (!name.ToLowerInvariant().EndsWith(".unity"))
                    && (!name.ToLowerInvariant().EndsWith("thumbs.db"))
                    && (!name.ToLowerInvariant().EndsWith(".orig"))
                    && (!name.ToLowerInvariant().Contains(Path.DirectorySeparatorChar + "heureka" + Path.DirectorySeparatorChar))
                    && (!name.ToLowerInvariant().Contains(Path.DirectorySeparatorChar + "plugins" + Path.DirectorySeparatorChar))
                    && (!name.ToLowerInvariant().Contains(Path.DirectorySeparatorChar + "streamingassets" + Path.DirectorySeparatorChar))
                    && (!name.ToLowerInvariant().Contains(Path.DirectorySeparatorChar + "resources" + Path.DirectorySeparatorChar))
                    && (!name.ToLowerInvariant().Contains(Path.DirectorySeparatorChar + "editor default resources" + Path.DirectorySeparatorChar))
                    && (!name.ToLowerInvariant().Contains(Path.DirectorySeparatorChar + "editor" + Path.DirectorySeparatorChar))
                    && (!name.ToLowerInvariant().EndsWith(@".ds_store"))
                    && (!name.ToLowerInvariant().EndsWith(@".workspace.mel"))
                    && (!name.ToLowerInvariant().EndsWith(@".mayaswatches")))
                    .ToArray();

            //TODO this could also be improved for performance
            for (int i = 0; i < assetsInDirectory.Length; i++)
            {
                assetsInDirectory[i] = assetsInDirectory[i].Substring(assetsInDirectory[i].IndexOf("/Assets") + 1);
                assetsInDirectory[i] = assetsInDirectory[i].Replace(@"\", "/");
            }

            //Find any assets that does not live in UsedAssets List
            //TODO for performance reasons, perhaps dont to this for each folder, but just once, when finished?
            //That would mean to do folder creation and populating unused assets lists after all folders are traversed
            var result = assetsInDirectory.Where(p => !usedAssets.Any(p2 => UnityEditor.AssetDatabase.GUIDToAssetPath(p2.GUID) == p));

            //Create new folder object
            ProjectFolderInfo afInfo = new ProjectFolderInfo();

            //TODO this could also be improved for performance
            afInfo.DirectoryName = path.Substring(path.IndexOf("/Assets") + 1).Replace(@"\", "/");
            afInfo.ParentIndex = parentIndex;

            if (heirarchyDepth == 0)
                afInfo.FoldOut = true;

            //Add to static list
            AssetHunterMainWindow.Instance.AddProjectFolderInfo(afInfo);

            if (parentIndex != -1)
            {
                AssetHunterMainWindow.Instance.GetFolderList()[parentIndex].AddChildFolder(afInfo);
            }

            UnityEngine.Object objToFind;
            foreach (string assetName in result)
            {
                bool bExclude = false;

                foreach (string excluder in AssetHunterMainWindow.Instance.settings.m_AssetSubstringExcludes)
                {
                    //Exlude Asset Exclude substrings from settings
                    //If we find an excluded asset just continue to next iteration in loop
                    if (assetName.Contains(excluder, StringComparison.OrdinalIgnoreCase))
                        bExclude = true;
                }
                if (bExclude)
                    continue;

                objToFind = AssetDatabase.LoadAssetAtPath(assetName, typeof(UnityEngine.Object));

                if (objToFind == null)
                {
                    Debug.LogWarning("Couldnt find " + assetName);
                    continue;
                }

                SerializableSystemType assetType = new SerializableSystemType(objToFind.GetType());

                if (assetType.SystemType != typeof(MonoScript) && (!AssetHunterMainWindow.Instance.settings.m_AssetTypeExcludes.Contains(assetType)))
                {
                    AssetObjectInfo newAssetInfo = new AssetObjectInfo(assetName, assetType);
                    afInfo.AddAsset(newAssetInfo);
                }

                objToFind = null;

                //Memory leak safeguard
                //This have heavy performance implications
                if(AssetHunterMainWindow.Instance.settings.m_MemoryCleanupActive)
                    UnloadUnused();
            }

            string[] nextLevelDirectories = System.IO.Directory.GetDirectories(path, "*.*", System.IO.SearchOption.TopDirectoryOnly);

            //Memory leak safeguard per folder
            if (!AssetHunterMainWindow.Instance.settings.m_MemoryCleanupActive)
                UnloadUnused();

            foreach (string nld in nextLevelDirectories)
            {
                traverseDirectory(AssetHunterMainWindow.Instance.GetFolderList().IndexOf(afInfo), nld, usedAssets, (heirarchyDepth + 1), ref directoriesTraversed, validTypeList);
            }
        }
Пример #16
0
        private static void traverseDirectory(int parentIndex, string path, List<BuildReportAsset> usedAssets, int heirarchyDepth, ref int directoriesTraversed, SortedDictionary<SerializableSystemType, bool> validTypeList)
        {
            directoriesTraversed++;

            EditorUtility.DisplayProgressBar(
                                "Traversing Directories",
                                "(" + directoriesTraversed + " of " + m_NumberOfDirectories + ") Analyzing " + path.Substring(path.IndexOf("/Assets") + 1),
                                (float)directoriesTraversed / (float)m_NumberOfDirectories);

            //Get the settings to exclude vertain folders or suffixes
            foreach (UnityEngine.Object dir in AssetHunterMainWindow.Instance.settings.m_DirectoryExcludes)
            {
                //TODO Can this be done more elegantly
                int startingIndex = Application.dataPath.Length-6;
                string relativePath = path.Substring(startingIndex, path.Length - startingIndex);
                UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(relativePath, typeof(UnityEngine.Object));

                if (dir == obj)
                {
                    //This folder was exluded
                    return;
                }
            }

            string[] assetsInDirectory = Directory.GetFiles(path, "*.*", SearchOption.TopDirectoryOnly)
                .Where(name => !name.ToLowerInvariant().EndsWith(".meta")
                    && (!name.ToLowerInvariant().EndsWith(".unity"))
                    && (!name.ToLowerInvariant().EndsWith("thumbs.db"))
                    && (!name.ToLowerInvariant().EndsWith(".orig"))
                    && (!name.ToLowerInvariant().Contains(Path.DirectorySeparatorChar + "heureka" + Path.DirectorySeparatorChar))
                    && (!name.ToLowerInvariant().Contains(Path.DirectorySeparatorChar + "plugins" + Path.DirectorySeparatorChar))
                    && (!name.ToLowerInvariant().Contains(Path.DirectorySeparatorChar + "streamingassets" + Path.DirectorySeparatorChar))
                    && (!name.ToLowerInvariant().Contains(Path.DirectorySeparatorChar + "resources" + Path.DirectorySeparatorChar))
                    && (!name.ToLowerInvariant().Contains(Path.DirectorySeparatorChar + "editor default resources" + Path.DirectorySeparatorChar))
                    && (!name.ToLowerInvariant().Contains(Path.DirectorySeparatorChar + "editor" + Path.DirectorySeparatorChar))
                    && (!name.ToLowerInvariant().Contains(@".ds_store"))
                    && (!name.ToLowerInvariant().Contains(@".workspace.mel"))
                    && (!name.ToLowerInvariant().Contains(@".mayaswatches")))
                    .ToArray();

            for (int i = 0; i < assetsInDirectory.Length; i++)
            {
                assetsInDirectory[i] = assetsInDirectory[i].Substring(assetsInDirectory[i].IndexOf("/Assets") + 1);
                assetsInDirectory[i] = assetsInDirectory[i].Replace(@"\", "/");
            }

            //Find any assets that does not live in UsedAssets List
            var result = assetsInDirectory.Where(p => !usedAssets.Any(p2 => UnityEditor.AssetDatabase.GUIDToAssetPath(p2.GUID) == p));

            //Create new folder object
            ProjectFolderInfo afInfo = new ProjectFolderInfo();

            afInfo.DirectoryName = path.Substring(path.IndexOf("/Assets") + 1).Replace(@"\", "/");
            afInfo.ParentIndex = parentIndex;

            if (heirarchyDepth == 0)
                afInfo.FoldOut = true;

            //Add to static list
            AssetHunterMainWindow.Instance.AddProjectFolderInfo(afInfo);

            if (parentIndex != -1)
            {
                AssetHunterMainWindow.Instance.GetFolderList()[parentIndex].AddChildFolder(afInfo);
            }

            UnityEngine.Object objToFind;
            foreach (string assetName in result)
            {
                objToFind = AssetDatabase.LoadAssetAtPath(assetName, typeof(UnityEngine.Object));

                if (objToFind == null)
                {
                    Debug.LogWarning("Couldnt find " + assetName);
                    continue;
                }

                SerializableSystemType assetType = new SerializableSystemType(objToFind.GetType());

                if (assetType.SystemType != typeof(MonoScript) && (!AssetHunterMainWindow.Instance.settings.m_AssetTypeExcludes.Contains(assetType)))
                {
                    AssetObjectInfo newAssetInfo = new AssetObjectInfo(assetName, assetType);
                    afInfo.AddAsset(newAssetInfo);
                }

                objToFind = null;

                //Memory leak safeguard
                UnloadUnused();
            }

            string[] nextLevelDirectories = System.IO.Directory.GetDirectories(path, "*.*", System.IO.SearchOption.TopDirectoryOnly);

            foreach (string nld in nextLevelDirectories)
            {
                traverseDirectory(AssetHunterMainWindow.Instance.GetFolderList().IndexOf(afInfo), nld, usedAssets, (heirarchyDepth + 1), ref directoriesTraversed, validTypeList);
            }
        }