Exemplo n.º 1
0
    private void loadEditorLog()
    {
        m_newBuildReady = false;

        m_ProjectFolderList.Clear();
        m_BuildLog = AssetHunterHelper.AnalyzeBuildLog();

        if (m_BuildLog.IsEmpty())
        {
            m_BuildLogLoaded = false;
            return;
        }
        else
        {
            m_BuildLogLoaded = true;
        }

        List <string> usedPrefabsInScenes = AssetReader.GetPrefabsFromSceneFiles(AssetReader.GetEnabledScenesInBuild(), out m_assetSceneDependencies);

        m_BuildLog.AddPrefabs(usedPrefabsInScenes);
        m_BuildLog.AddPlatformSpecificAssets();

        AssetHunterHelper.PopulateUnusedList(m_BuildLog, m_unusedTypeDict);

        refreshUnusedAssets();
    }
 private void GetSceneInfo()
 {
     m_allScenesInProject               = AssetHunterHelper.GetAllSceneNames().ToList <string>();
     m_allScenesInBuildSettings         = AssetHunterHelper.GetAllSceneNamesInBuild().ToList <string>();
     m_allEnabledScenesInBuildSettings  = AssetHunterHelper.GetEnabledSceneNamesInBuild().ToList <string>();
     m_allDisabledScenesInBuildSettings = SubtractSceneArrays(m_allScenesInBuildSettings, m_allEnabledScenesInBuildSettings);
     m_allUnreferencedScenes            = SubtractSceneArrays(m_allScenesInProject, m_allScenesInBuildSettings);
 }
Exemplo n.º 3
0
    private static AssetHunterMainWindow doInit()
    {
        m_IntialGUIColor = GUI.color;

        m_window = EditorWindow.GetWindow <AssetHunterMainWindow>();
        m_window.Show();

        loadEditorResources();

        m_window.m_BuildLogExists = AssetHunterHelper.HasBuildLogAvaliable();

        return(m_window);
    }
Exemplo n.º 4
0
    private void OnShowDefaultGUI()
    {
        EditorGUILayout.LabelField("Asset Hunter v1.3.5", EditorStyles.boldLabel);

        //Show logo
        if (m_window && m_window.m_UIWideLogo)
        {
            GUILayout.Label(m_window.m_UIWideLogo);
        }

        //If there is no valid build log
        if (!m_BuildLogExists)
        {
            m_BuildLogExists = AssetHunterHelper.HasBuildLogAvaliable();

            if (!m_BuildLogExists)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(m_UIWarning);
                GUILayout.Label("Go build your project in order for this tool to function...(Ctrl+Shift+B)", EditorStyles.boldLabel);
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();
            }
        }

        string buildLogButtonText;

        //Settings
        EditorGUILayout.Space();
        EditorGUILayout.BeginVertical();
        if (GUILayout.Button(new GUIContent("Edit Settings", m_UISettings), GUILayout.Width(btnMinWidth - 70), GUILayout.Height(20)))
        {
            EditorWindow.GetWindow <AssetHunterSettingsWindow>(true, "Asset Hunter Settings");
        }


        EditorGUI.indentLevel = 0;

        //Only show the foldout if we actually have any manually excluded folders or types
        if (settings.HasExcludes())
        {
            bShowExcludeFoldout = EditorGUILayout.Foldout(bShowExcludeFoldout, "Show manual excludes");
        }

        if (bShowExcludeFoldout)
        {
            if (settings.HasDirectoryExcludes())
            {
                EditorGUI.indentLevel = 1;
                EditorGUILayout.LabelField("Excluded Directories", EditorStyles.boldLabel);

                EditorGUI.indentLevel = 2;
                foreach (Object obj in settings.m_DirectoryExcludes)
                {
                    EditorGUILayout.LabelField(AssetDatabase.GetAssetPath(obj), EditorStyles.miniLabel);
                }
            }
            if (settings.HasTypeExcludes())
            {
                EditorGUI.indentLevel = 1;
                EditorGUILayout.LabelField("Excluded Types", EditorStyles.boldLabel);

                EditorGUI.indentLevel = 2;
                foreach (SerializableSystemType sType in settings.m_AssetTypeExcludes)
                {
                    EditorGUILayout.LabelField(sType.Name);
                }
            }
        }

        EditorGUI.indentLevel = 0;
        EditorGUILayout.EndVertical();

        GUILayout.Label("-------------------------------Build Log--------------------------------");

        //If build log up to date
        if (!m_newBuildReady)
        {
            buildLogButtonText = m_BuildLogLoaded ? "Log updated (refresh)" : "Load Build Log (Required)";
            GUI.color          = m_BuildLogLoaded ? Color.green : Color.red;
        }

        //If build log outdated
        else
        {
            buildLogButtonText = "Log outdated(Refresh)";
            GUI.color          = Color.yellow;
        }

        EditorGUILayout.BeginHorizontal();

        //Load the Editor build log
        if (GUILayout.Button(buildLogButtonText, GUILayout.MinWidth(btnMinWidth)))
        {
            loadEditorLog();
            return;
        }
        EditorGUILayout.Space();

        GUI.color = Color.cyan;

        if (GUILayout.Button("Open Log", GUILayout.MinWidth(btnMinWidth)))
        {
            System.Diagnostics.Process.Start(AssetHunterHelper.GetLogFolderPath());
        }

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

        GUILayout.Label("------------------------------Select Mode------------------------------");
        EditorGUILayout.BeginHorizontal();

        //Choose window state
        GUI.color = (m_WindowState == AssetHunterWindowState.UnusedAssets) ? Color.gray : m_IntialGUIColor;
        if (GUILayout.Button(AssetHunterWindowState.UnusedAssets.ToString(), GUILayout.MinWidth(btnMinWidth)))
        {
            changeState(AssetHunterWindowState.UnusedAssets);
        }
        EditorGUILayout.Space();
        GUI.color = (m_WindowState == AssetHunterWindowState.BuildReport) ? Color.gray : m_IntialGUIColor;
        if (GUILayout.Button(AssetHunterWindowState.BuildReport.ToString(), GUILayout.MinWidth(btnMinWidth)))
        {
            //AssetHunterHelper.GetAddedComponents();
            changeState(AssetHunterWindowState.BuildReport);
        }

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

        //Reset GUI Color
        GUI.color = m_IntialGUIColor;
    }
    private void OnShowDefaultGUI()
    {
        EditorGUILayout.LabelField("Asset Hunter v1.2.1", EditorStyles.boldLabel);
        //Show logo
        if (m_window && m_window.m_UIWideLogo)
        {
            GUILayout.Label(m_window.m_UIWideLogo);
        }

        //If there is no valid build log
        if (!m_BuildLogExists)
        {
            m_BuildLogExists = AssetHunterHelper.HasBuildLogAvaliable();

            if (!m_BuildLogExists)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(m_UIWarning);
                GUILayout.Label("Go build your project in order for this tool to function...(Ctrl+Shift+B)", EditorStyles.boldLabel);
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();
            }
        }

        Color  intialGUIColor = GUI.color;
        string buildLogButtonText;

        //If build log up to date
        if (!m_newBuildReady)
        {
            buildLogButtonText = m_BuildLogLoaded ? "Log updated (refresh)" : "Load Build Log (Required)";
            GUI.color          = m_BuildLogLoaded ? Color.green : Color.red;
        }
        //If build log outdated
        else
        {
            buildLogButtonText = "Log outdated(Refresh)";
            GUI.color          = Color.yellow;
        }

        EditorGUILayout.BeginHorizontal();
        float btnMinWidth = 180;

        //Load the Editor build log
        if (GUILayout.Button(buildLogButtonText, GUILayout.MinWidth(btnMinWidth)))
        {
            loadEditorLog();
            return;
        }
        EditorGUILayout.Space();

        GUI.color = Color.cyan;

        if (GUILayout.Button("Open Log", GUILayout.MinWidth(btnMinWidth)))
        {
            System.Diagnostics.Process.Start(AssetHunterHelper.GetLogFolderPath());
        }

        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();
        GUILayout.Label("------------------------------Select Mode------------------------------");
        EditorGUILayout.BeginHorizontal();

        //Choose window state
        GUI.color = (m_WindowState == AssetHunterWindowState.UnusedAssets) ? Color.gray : intialGUIColor;
        if (GUILayout.Button(AssetHunterWindowState.UnusedAssets.ToString(), GUILayout.MinWidth(btnMinWidth)))
        {
            m_WindowState = AssetHunterWindowState.UnusedAssets;
        }
        EditorGUILayout.Space();
        GUI.color = (m_WindowState == AssetHunterWindowState.BuildReport) ? Color.gray : intialGUIColor;
        if (GUILayout.Button(AssetHunterWindowState.BuildReport.ToString(), GUILayout.MinWidth(btnMinWidth)))
        {
            m_WindowState = AssetHunterWindowState.BuildReport;
        }

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

        //Reset GUI Color
        GUI.color = intialGUIColor;
    }
Exemplo n.º 6
0
    private void OnShowDefaultBody()
    {
        EditorGUILayout.BeginVertical();

        //Draw excluded types foldout
        if (bShowExcludeFoldout)
        {
            GUILayout.Label("-------------------------------------------------------------------------");
            if (settings.HasDirectoryExcludes())
            {
                GUI.color             = AssetHunterHelper.AH_BLUE;
                EditorGUI.indentLevel = 1;
                EditorGUILayout.LabelField("Excluded Directories", EditorStyles.whiteBoldLabel);
                GUI.color             = m_IntialGUIColor;
                EditorGUI.indentLevel = 2;
                foreach (UnityEngine.Object obj in settings.m_DirectoryExcludes)
                {
                    EditorGUILayout.LabelField(AssetDatabase.GetAssetPath(obj), EditorStyles.miniLabel);
                }
            }
            if (settings.HasTypeExcludes())
            {
                GUI.color             = AssetHunterHelper.AH_BLUE;
                EditorGUI.indentLevel = 1;
                EditorGUILayout.LabelField("Excluded Types", EditorStyles.whiteBoldLabel);
                GUI.color             = m_IntialGUIColor;
                EditorGUI.indentLevel = 2;
                foreach (SerializableSystemType sType in settings.m_AssetTypeExcludes)
                {
                    EditorGUILayout.LabelField(sType.Name);
                }
            }
            if (settings.HasSubStringExcludes())
            {
                GUI.color             = AssetHunterHelper.AH_BLUE;
                EditorGUI.indentLevel = 1;
                EditorGUILayout.LabelField("Excluded Strings", EditorStyles.whiteBoldLabel);
                GUI.color             = m_IntialGUIColor;
                EditorGUI.indentLevel = 2;
                foreach (string substring in settings.m_AssetSubstringExcludes)
                {
                    EditorGUILayout.LabelField(substring);
                }
            }
            GUILayout.Label("-------------------------------------------------------------------------");
            GUILayout.Space(10);
        }

        //If there is no valid build log
        if (!m_BuildLogExists)
        {
            m_BuildLogExists = AssetHunterHelper.HasBuildLogAvaliable();

            if (!m_BuildLogExists)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(m_UIWarning);
                GUILayout.Label("Asset Hunter needs a recent build in order to work", EditorStyles.boldLabel);
                EditorGUILayout.EndHorizontal();

                GUILayout.Label("Create a build (Ctrl+Shift+B)");

                //requires unity 5 to work
                #if UNITY_5
                if (GUILayout.Button("Open Build Settings"))
                {
                    EditorWindow.GetWindow(Type.GetType("UnityEditor.BuildPlayerWindow,UnityEditor"));
                }
                #endif

                GUILayout.FlexibleSpace();
                return;
            }
        }

        string buildLogButtonText;

        EditorGUI.indentLevel = 0;
        EditorGUILayout.EndVertical();

        GUILayout.Label("-------------------------------Build Info--------------------------------");

        //If build log up to date
        if (!m_newBuildReady)
        {
            buildLogButtonText = m_BuildLogLoaded ? "Log updated (refresh)" : "Load Build Log (Required)";
            GUI.color          = m_BuildLogLoaded ? AssetHunterHelper.AH_GREEN : AssetHunterHelper.AH_RED;
        }

        //If build log outdated
        else
        {
            buildLogButtonText = "Log outdated(Refresh)";
            GUI.color          = AssetHunterHelper.AH_YELLOW1;
        }

        //Load the Editor build log
        if (GUILayout.Button(buildLogButtonText, GUILayout.Width(375)))
        {
            loadEditorLog();
            return;
        }
        //GUILayout.FlexibleSpace();
        EditorGUILayout.Space();

        GUILayout.Label("------------------------------Select Mode------------------------------");
        EditorGUILayout.BeginHorizontal();

        //Choose window state
        GUI.color = (m_WindowState == AssetHunterWindowState.UnusedAssets) ? AssetHunterHelper.AH_GREY : m_IntialGUIColor;
        if (GUILayout.Button(AssetHunterWindowState.UnusedAssets.ToString(), GUILayout.MinWidth(btnMinWidth)))
        {
            changeState(AssetHunterWindowState.UnusedAssets);
        }
        EditorGUILayout.Space();

        GUI.color = (m_WindowState == AssetHunterWindowState.BuildReport) ? AssetHunterHelper.AH_GREY : m_IntialGUIColor;
        if (GUILayout.Button(AssetHunterWindowState.BuildReport.ToString(), GUILayout.MinWidth(btnMinWidth)))
        {
            //Shot buildreport
            changeState(AssetHunterWindowState.BuildReport);
        }

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

        #region scriptdetection

        /*EditorGUILayout.BeginHorizontal();
         *
         * GUI.color = AssetHunterHelper.AH_RED;
         * if (GUILayout.Button(AssetHunterWindowState.UnusedScripts.ToString() + " (WIP - USE WITH CONSIDERATION)", GUILayout.MinWidth(btnMinWidth * 2 + 14)))
         * {
         *
         *  GUI.color = m_IntialGUIColor;
         *  //Get added scripts
         *  //List<Type> scriptAssemblyTypes = AssetHunterHelper.GetScriptAssembly();
         *
         *  //Find all enabled scenes in buildsettings
         *  EditorBuildSettingsScene[] activeScenes = EditorBuildSettings.scenes.Where(val => val.enabled == true).ToArray<EditorBuildSettingsScene>();
         *
         *
         *  //All script dependencies for all enabled levels in buildsettings
         *  m_UsedScriptList = AssetHunterHelper.GetScriptLevelDependencies(activeScenes);
         *
         *  //Find ALL scripts in scriptAssembly
         *  //TODO ADD THIS TO ATTEMPT TO LOCATE UNUSED CODE
         *  //m_UnusedScriptList = AssetHunterHelper.GetAddedComponents();
         *
         *  //Remove "Used Scripts" from list
         *  m_UnusedScriptList.RemoveAll(val => m_UsedScriptList.Contains(val));
         *
         *  changeState(AssetHunterWindowState.UnusedScripts);
         * }
         *
         * GUILayout.FlexibleSpace();
         * EditorGUILayout.EndHorizontal();
         * EditorGUILayout.Space();*/

        #endregion

        //Reset GUI Color
        GUI.color = m_IntialGUIColor;
    }
Exemplo n.º 7
0
    private void OnShowDefaultHeader()
    {
        EditorGUILayout.LabelField("Asset Hunter v2.1.2", EditorStyles.boldLabel);
        EditorGUILayout.BeginVertical();
        EditorGUILayout.BeginHorizontal();

        //BUTTON Settings
        EditorGUILayout.Space();
        // GUI.color = AssetHunterHelper.AH_BLUE;
        if (GUILayout.Button(new GUIContent("Edit settings", m_UISettings), GUILayout.Width(btnMinWidth - 70), GUILayout.Height(20)))
        {
            EditorWindow.GetWindow <AssetHunterSettingsWindow>(true, "Asset Hunter Settings");
        }

        //BUTTON Open Log
        EditorGUILayout.Space();
        //GUI.color = AssetHunterHelper.AH_RED;
        if (GUILayout.Button("Open log", GUILayout.MinWidth(100)))
        {
            System.Diagnostics.Process.Start(AssetHunterHelper.GetLogFolderPath());
        }

        //BUTTON delete empty folders
        EditorGUILayout.Space();
        //GUI.color = AssetHunterHelper.AH_BLUE;
        if (GUILayout.Button("Delete empty folders", GUILayout.MinWidth(120)))
        {
            if (EditorUtility.DisplayDialog("Delete empty folder", "Are you sure you want to delete all empty folders", "Yes", "No"))
            {
                string path        = Application.dataPath;
                int    deleteCount = 0;
                deleteEmptyDirectories(path, ref deleteCount);

                Debug.LogWarning(deleteCount + " empty folders was deleted by Asset Hunter");
            }
        }

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

        GUILayout.Space(5);

        EditorGUILayout.BeginHorizontal();

        //BUTTON Settings
        EditorGUILayout.Space();
        if (GUILayout.Button("Scene overview", GUILayout.Width(btnMinWidth - 70), GUILayout.Height(20)))
        {
            EditorWindow.GetWindow <AssetHunterSceneOverview>(true, "Asset Hunter Scene Overview");
        }

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

        EditorGUILayout.Space();

        GUI.color = m_IntialGUIColor;

        //Show logo
        if (m_window && m_window.m_UIWideLogo)
        {
            GUILayout.Label(m_window.m_UIWideLogo);
        }

        //Only show the foldout if we actually have any manually excluded folders or types
        if (settings != null && settings.HasExcludes())
        {
            bShowExcludeFoldout = EditorGUILayout.Foldout(bShowExcludeFoldout, "Show manual excludes");
        }

        EditorGUILayout.EndVertical();
    }