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

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

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


            List <string> usedPrefabsInScenes = AHReader.GetPrefabsFromSceneFiles(AHHelper.GetEnabledSceneNamesInBuild(), out m_assetSceneDependencies);

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

            AHHelper.PopulateUnusedList(m_BuildLog, m_unusedTypeDict);

            refreshUnusedAssets();
        }
Esempio n. 2
0
        internal static void PopulateUnusedList(AHBuildReport buildLog, SortedDictionary <AHSerializableSystemType, bool> validTypeList)
        {
            //Count all directories in project for use in progress bar
            m_NumberOfDirectories = System.IO.Directory.GetDirectories(Application.dataPath, "*.*", System.IO.SearchOption.AllDirectories).Length;
            int directoriesTraversed = 0;

            //traverse directories
            traverseDirectory(-1, Application.dataPath, buildLog.m_BuildSizeList, 0, ref directoriesTraversed, validTypeList);
            EditorUtility.ClearProgressBar();
        }
Esempio n. 3
0
        internal static AHBuildReport AnalyzeBuildLog()
        {
            AHBuildReport buildReport        = new AHBuildReport();
            string        UnityEditorLogfile = GetLogFolderPath();

            try
            {
                // Have to use FileStream to get around sharing violations!
                FileStream   FS = new FileStream(UnityEditorLogfile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                StreamReader SR = new StreamReader(FS);

                string line;
                int    linesRead = 0;
                int    lineIndex = 0;

                while (!SR.EndOfStream)
                {
                    line = SR.ReadLine();
                    linesRead++;
                    if ((line).Contains("Mono dependencies included in the build"))
                    {
                        lineIndex = linesRead;
                    }
                }

                FS.Position = 0;
                SR.DiscardBufferedData();

                //Start reading from log at the right line
                for (int i = 0; i < lineIndex - 1; i++)
                {
                    SR.ReadLine();
                }

                while (!SR.EndOfStream && !(line = SR.ReadLine()).Contains("Mono dependencies included in the build"))
                {
                    ;
                }
                while (!SR.EndOfStream && (line = SR.ReadLine()) != "")
                {
                    int stringLength = line.Length;
                    int startIndex   = line.LastIndexOf(" ");
                    buildReport.AddDependency(line.Substring(startIndex, stringLength - startIndex));
                }
                while (!SR.EndOfStream && !(line = SR.ReadLine()).Contains("Used Assets"))
                {
                    ;
                }
                bool assetAnalysisComplete = false;
                while (!SR.EndOfStream && !assetAnalysisComplete)
                {
                    string curLine = SR.ReadLine();

                    if (curLine == "" || curLine.Contains("System memory in use before") || !curLine.Contains("% "))
                    {
                        assetAnalysisComplete = true;
                    }
                    else
                    {
                        if (!curLine.Contains("Built-in"))
                        {
                            string str = curLine.Substring(curLine.IndexOf("% ") + 2);
                            if (str.StartsWith("assets/", true, null))
                            {
                                EditorUtility.DisplayProgressBar(
                                    "Parsing build log",
                                    "Parsing build log to retrieve info",
                                    (float)SR.BaseStream.Position / (float)SR.BaseStream.Length);

                                UnityEngine.Object obj = UnityEditor.AssetDatabase.LoadAssetAtPath(str, typeof(UnityEngine.Object));

                                if (obj != null)
                                {
                                    BuildReportAsset asset = new BuildReportAsset();

                                    asset.SetAssetInfo(obj, str);
                                    buildReport.AddAsset(asset);
                                }
                                else
                                {
                                    Debug.Log(str + " does not seem to be a valid asset (Maybe its a \"terrain folder\"");
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception E)
            {
                Debug.LogError("Error: " + E);
            }
            EditorUtility.ClearProgressBar();

            return(buildReport);
        }