Exemplo n.º 1
0
    static BuildSizePart[] ParseBuildSizePartsFromString(string inText)
    {
        // now parse the build parts to an array of `BuildSizePart`
        List <BuildSizePart> buildSizes = new List <BuildSizePart>();

        string[] buildPartsSplitted = inText.Split(new Char[] { '\n', '\r' });
        foreach (string b in buildPartsSplitted)
        {
            if (!string.IsNullOrEmpty(b))
            {
                //Debug.Log("got: " + b);

                string gotName    = "";
                string gotSize    = "";
                string gotPercent = "";

                Match match = Regex.Match(b, @"^[a-z \t]+[^0-9]", RegexOptions.IgnoreCase);
                if (match.Success)
                {
                    gotName = match.Groups[0].Value;
                    gotName = gotName.Trim();
                    //Debug.Log("    name? " + gotName);
                }

                match = Regex.Match(b, @"[0-9.]+ (kb|mb|b|gb)", RegexOptions.IgnoreCase);
                if (match.Success)
                {
                    gotSize = match.Groups[0].Value.ToUpper();
                    //Debug.Log("    size? " + gotSize);
                }

                match = Regex.Match(b, @"[0-9.]+%", RegexOptions.IgnoreCase);
                if (match.Success)
                {
                    gotPercent = match.Groups[0].Value;
                    gotPercent = gotPercent.Substring(0, gotPercent.Length - 1);
                    //Debug.Log("    percent? " + gotPercent);
                }

                BuildSizePart inPart = new BuildSizePart();
                inPart.Name       = gotName;
                inPart.Size       = gotSize;
                inPart.Percentage = Double.Parse(gotPercent);
                buildSizes.Add(inPart);
            }
        }

        return(buildSizes.ToArray());
    }
Exemplo n.º 2
0
    public void Init(string inProjectName, string inBuildType, BuildSizePart[] inBuildSizes, string inTotalSize, string inCompressedSize, BuildSizePart[] inAssetSizes, string inMonoDLLs)
    {
        _projectName = inProjectName;
        _buildType = inBuildType;
        _buildSizes = inBuildSizes;
        _totalBuildSize = inTotalSize;
        _compressedBuildSize = inCompressedSize;
        _assetSizes = inAssetSizes;
        _monoDLLs = inMonoDLLs;

        string guiSkinToUse = "BuildReportWindow.guiskin";
        if (EditorGUIUtility.isProSkin)
        {
            guiSkinToUse = "BuildReportWindowDark.guiskin";
        }

        // try default path
        _usedSkin = AssetDatabase.LoadAssetAtPath("Assets/BuildReport/GUI/" + guiSkinToUse, typeof(GUISkin)) as GUISkin;

        if (_usedSkin == null)
        {
            Debug.LogWarning("BuildReport package seems to have been moved. Finding...");

            string folderPath = FindAssetFolder(Application.dataPath, "BuildReport");
            folderPath = folderPath.Replace('\\', '/');
            int assetsIdx = folderPath.IndexOf("/Assets/");
            if (assetsIdx != -1)
            {
                folderPath = folderPath.Substring(assetsIdx+8, folderPath.Length-assetsIdx-8);
            }
            //Debug.Log(folderPath);

            _usedSkin = AssetDatabase.LoadAssetAtPath("Assets/" + folderPath + "/GUI/" + guiSkinToUse, typeof(GUISkin)) as GUISkin;
            //Debug.Log("_usedSkin " + (_usedSkin != null));
        }
    }
Exemplo n.º 3
0
    public static void GetValues(out string projectName, out string buildType, out BuildSizePart[] buildSizes, out string totalBuildSize, out string compressedBuildSize, out BuildSizePart[] assetSizes, out string DLLs)
    {
        //Debug.Log(EditorLogContents);

        projectName = ProjectName;
//		Debug.Log("projectName:"+projectName);
        string editorLog = EditorLogContents;

        editorLog = editorLog.Replace("\r\n", "\n");
//		Debug.Log("editorLog:"+editorLog);
        const string REPORT_START_KEY = "100.0% \n\nUsed Assets, sorted by uncompressed size:";

        int usedAssetsIdx = editorLog.LastIndexOf(REPORT_START_KEY);

        if (usedAssetsIdx == -1)
        {
            Debug.LogWarning("Build Report Window: No build info found in current session. Looking at data from previous session...");
            editorLog = EditorPrevLogContents;
            editorLog = editorLog.Replace("\r\n", "\n");
        }

        usedAssetsIdx = editorLog.LastIndexOf(REPORT_START_KEY);

        if (usedAssetsIdx == -1)
        {
            Debug.LogWarning("Build Report Window: No build info found. Build the project first.");
            buildType           = "";
            buildSizes          = new BuildSizePart[0];
            totalBuildSize      = "";
            compressedBuildSize = "";
            assetSizes          = new BuildSizePart[0];
            DLLs = "";
            return;
        }

//		Debug.Log("usedAssetsIdx: " + usedAssetsIdx);

        int texturesIdx = editorLog.LastIndexOf("Textures", usedAssetsIdx);
//		Debug.Log("texturesIdx: " + texturesIdx);

        int completeSizeIdx = editorLog.IndexOf("Complete size ", texturesIdx);

//		Debug.Log("completeSizeIdx: " + completeSizeIdx);

        completeSizeIdx = editorLog.IndexOf("\n", completeSizeIdx);

        string buildParts = editorLog.Substring(texturesIdx, completeSizeIdx - texturesIdx);

//		Debug.Log("count: " + (completeSizeIdx-texturesIdx));


//		Debug.Log("STA\n" + buildParts + "\nEND\n");

        buildSizes = ParseBuildSizePartsFromString(buildParts);

        totalBuildSize = "";

        foreach (BuildSizePart b in buildSizes)
        {
            if (b.IsTotal)
            {
                totalBuildSize = b.Size;
            }
        }

        compressedBuildSize = "";
        const string COMPRESSED_BUILD_SIZE_KEY = "Total compressed size ";
        int          compressedBuildSizeIdx    = editorLog.LastIndexOf(COMPRESSED_BUILD_SIZE_KEY, usedAssetsIdx, 800);

        if (compressedBuildSizeIdx != -1)
        {
            int compressedBuildSizeEndIdx = editorLog.IndexOf(". Total uncompressed size ", compressedBuildSizeIdx);
            compressedBuildSize = editorLog.Substring(compressedBuildSizeIdx + COMPRESSED_BUILD_SIZE_KEY.Length, compressedBuildSizeEndIdx - compressedBuildSizeIdx - COMPRESSED_BUILD_SIZE_KEY.Length);
            //Debug.Log("compressed: " + compressedBuildSize);
        }

        Array.Sort(buildSizes, delegate(BuildSizePart b1, BuildSizePart b2) {
            if (b1.Percentage > b2.Percentage)
            {
                return(-1);
            }
            if (b1.Percentage < b2.Percentage)
            {
                return(1);
            }
            return(0);
        });

        buildType = GetBuildTypeFromEditorLog(editorLog);


        assetSizes = ParseAssetSizesFromEditorLog(editorLog, usedAssetsIdx + REPORT_START_KEY.Length);

        const string MONO_DLL_KEY   = "Mono dependencies included in the build\n";
        int          monoDllsStaIdx = editorLog.LastIndexOf(MONO_DLL_KEY, texturesIdx);
        int          monoDllsEndIdx = editorLog.IndexOf("\n\n", monoDllsStaIdx);

        DLLs = editorLog.Substring(monoDllsStaIdx + MONO_DLL_KEY.Length, monoDllsEndIdx - monoDllsStaIdx - MONO_DLL_KEY.Length);
        //Debug.Log("STA\n" + monoDlls + "\nEND\n");
    }
Exemplo n.º 4
0
    static BuildSizePart[] ParseAssetSizesFromEditorLog(string editorLog, int offset)
    {
        List <BuildSizePart> assetSizes = new List <BuildSizePart>();
        int assetListStaIdx             = editorLog.IndexOf("\n", offset);
        //Debug.Log("assetListStaIdx: " + assetListStaIdx);

        //Debug.Log(editorLog.Substring(assetListStaIdx, 500));

        int currentIdx = assetListStaIdx + 1;

        while (true)
        {
            int    lineEndIdx = editorLog.IndexOf("\n", currentIdx);
            string line       = editorLog.Substring(currentIdx, lineEndIdx - currentIdx);
            //Debug.Log("line: " + line);

            Match match = Regex.Match(line, @"^ [0-9].*[a-z0-9 ]$", RegexOptions.IgnoreCase);
            if (match.Success)
            {
                // it's an asset entry. parse it
                //string b = match.Groups[0].Value;

                string gotName    = "???";
                string gotSize    = "?";
                string gotPercent = "?";

                match = Regex.Match(line, @"Assets/.+", RegexOptions.IgnoreCase);
                if (match.Success)
                {
                    gotName = match.Groups[0].Value;
                    gotName = gotName.Trim();
                    //Debug.Log("    name? " + gotName);
                }

                match = Regex.Match(line, @"[0-9.]+ (kb|mb|b|gb)", RegexOptions.IgnoreCase);
                if (match.Success)
                {
                    gotSize = match.Groups[0].Value.ToUpper();
                    //Debug.Log("    size? " + gotSize);
                }
                else
                {
                    Debug.Log("didn't find size for :" + line);
                }

                match = Regex.Match(line, @"[0-9.]+%", RegexOptions.IgnoreCase);
                if (match.Success)
                {
                    gotPercent = match.Groups[0].Value;
                    gotPercent = gotPercent.Substring(0, gotPercent.Length - 1);
                    //Debug.Log("    percent? " + gotPercent);
                }
                else
                {
                    Debug.Log("didn't find percent for :" + line);
                }
                //Debug.Log("got: " + gotName + " size: " + gotSize);

                BuildSizePart inPart = new BuildSizePart();
                inPart.Name       = gotName;
                inPart.Size       = gotSize;
                inPart.Percentage = Double.Parse(gotPercent);
                assetSizes.Add(inPart);
            }
            else
            {
                break;
            }
            currentIdx = lineEndIdx + 1;
        }
        return(assetSizes.ToArray());
    }
Exemplo n.º 5
0
    static BuildSizePart[] ParseBuildSizePartsFromString(string inText)
    {
        // now parse the build parts to an array of `BuildSizePart`
        List<BuildSizePart> buildSizes = new List<BuildSizePart>();

        string[] buildPartsSplitted = inText.Split(new Char[] {'\n', '\r'});
        foreach (string b in buildPartsSplitted)
        {
            if (!string.IsNullOrEmpty(b))
            {
                //Debug.Log("got: " + b);

                string gotName = "";
                string gotSize = "";
                string gotPercent = "";

                Match match = Regex.Match(b, @"^[a-z \t]+[^0-9]", RegexOptions.IgnoreCase);
                if (match.Success)
                {
                    gotName = match.Groups[0].Value;
                    gotName = gotName.Trim();
                    //Debug.Log("    name? " + gotName);
                }

                match = Regex.Match(b, @"[0-9.]+ (kb|mb|b|gb)", RegexOptions.IgnoreCase);
                if (match.Success)
                {
                    gotSize = match.Groups[0].Value.ToUpper();
                    //Debug.Log("    size? " + gotSize);
                }

                match = Regex.Match(b, @"[0-9.]+%", RegexOptions.IgnoreCase);
                if (match.Success)
                {
                    gotPercent = match.Groups[0].Value;
                    gotPercent = gotPercent.Substring(0, gotPercent.Length-1);
                    //Debug.Log("    percent? " + gotPercent);
                }

                BuildSizePart inPart = new BuildSizePart();
                inPart.Name = gotName;
                inPart.Size = gotSize;
                inPart.Percentage = Double.Parse(gotPercent);
                buildSizes.Add(inPart);
            }
        }

        return buildSizes.ToArray();
    }
Exemplo n.º 6
0
    static BuildSizePart[] ParseAssetSizesFromEditorLog(string editorLog, int offset)
    {
        List<BuildSizePart> assetSizes = new List<BuildSizePart>();
        int assetListStaIdx = editorLog.IndexOf("\n", offset);
        //Debug.Log("assetListStaIdx: " + assetListStaIdx);

        //Debug.Log(editorLog.Substring(assetListStaIdx, 500));

        int currentIdx = assetListStaIdx+1;
        while (true)
        {
            int lineEndIdx = editorLog.IndexOf("\n", currentIdx);
            string line = editorLog.Substring(currentIdx, lineEndIdx-currentIdx);
            //Debug.Log("line: " + line);

            Match match = Regex.Match(line, @"^ [0-9].*[a-z0-9 ]$", RegexOptions.IgnoreCase);
            if (match.Success)
            {
                // it's an asset entry. parse it
                //string b = match.Groups[0].Value;

                string gotName = "???";
                string gotSize = "?";
                string gotPercent = "?";

                match = Regex.Match(line, @"Assets/.+", RegexOptions.IgnoreCase);
                if (match.Success)
                {
                    gotName = match.Groups[0].Value;
                    gotName = gotName.Trim();
                    //Debug.Log("    name? " + gotName);
                }

                match = Regex.Match(line, @"[0-9.]+ (kb|mb|b|gb)", RegexOptions.IgnoreCase);
                if (match.Success)
                {
                    gotSize = match.Groups[0].Value.ToUpper();
                    //Debug.Log("    size? " + gotSize);
                }
                else
                {
                    Debug.Log("didn't find size for :" + line);
                }

                match = Regex.Match(line, @"[0-9.]+%", RegexOptions.IgnoreCase);
                if (match.Success)
                {
                    gotPercent = match.Groups[0].Value;
                    gotPercent = gotPercent.Substring(0, gotPercent.Length-1);
                    //Debug.Log("    percent? " + gotPercent);
                }
                else
                {
                    Debug.Log("didn't find percent for :" + line);
                }
                //Debug.Log("got: " + gotName + " size: " + gotSize);

                BuildSizePart inPart = new BuildSizePart();
                inPart.Name = gotName;
                inPart.Size = gotSize;
                inPart.Percentage = Double.Parse(gotPercent);
                assetSizes.Add(inPart);

            }
            else
            {
                break;
            }
            currentIdx = lineEndIdx+1;
        }
        return assetSizes.ToArray();
    }
Exemplo n.º 7
0
    public static void GetValues(out string projectName, out string buildType, out BuildSizePart[] buildSizes, out string totalBuildSize, out string compressedBuildSize, out BuildSizePart[] assetSizes, out string DLLs)
    {
        //Debug.Log(EditorLogContents);

        projectName = ProjectName;

        string editorLog = EditorLogContents;
        editorLog = editorLog.Replace("\r\n", "\n");

        const string REPORT_START_KEY = "100.0% \n\nUsed Assets, sorted by uncompressed size:";

        int usedAssetsIdx = editorLog.LastIndexOf(REPORT_START_KEY);

        if (usedAssetsIdx == -1)
        {
            Debug.LogWarning("Build Report Window: No build info found in current session. Looking at data from previous session...");
            editorLog = EditorPrevLogContents;
            editorLog = editorLog.Replace("\r\n", "\n");
        }

        usedAssetsIdx = editorLog.LastIndexOf(REPORT_START_KEY);

        if (usedAssetsIdx == -1)
        {
            Debug.LogWarning("Build Report Window: No build info found. Build the project first.");
            buildType = "";
            buildSizes = new BuildSizePart[0];
            totalBuildSize = "";
            compressedBuildSize = "";
            assetSizes = new BuildSizePart[0];
            DLLs = "";
            return;
        }

        //Debug.Log("usedAssetsIdx: " + usedAssetsIdx);

        int texturesIdx = editorLog.LastIndexOf("Textures", usedAssetsIdx);
        //Debug.Log("texturesIdx: " + texturesIdx);

        int completeSizeIdx = editorLog.IndexOf("Complete size ", texturesIdx);
        //Debug.Log("completeSizeIdx: " + completeSizeIdx);

        completeSizeIdx = editorLog.IndexOf("\n", completeSizeIdx);

        string buildParts = editorLog.Substring(texturesIdx, completeSizeIdx-texturesIdx);
        //Debug.Log("count: " + (completeSizeIdx-texturesIdx));

        //Debug.Log("STA\n" + buildParts + "\nEND\n");

        buildSizes = ParseBuildSizePartsFromString(buildParts);

        totalBuildSize = "";

        foreach (BuildSizePart b in buildSizes)
        {
            if (b.IsTotal)
            {
                totalBuildSize = b.Size;
            }
        }

        compressedBuildSize = "";
        const string COMPRESSED_BUILD_SIZE_KEY = "Total compressed size ";
        int compressedBuildSizeIdx = editorLog.LastIndexOf(COMPRESSED_BUILD_SIZE_KEY, usedAssetsIdx, 800);
        if (compressedBuildSizeIdx != -1)
        {
            int compressedBuildSizeEndIdx = editorLog.IndexOf(". Total uncompressed size ", compressedBuildSizeIdx);
            compressedBuildSize = editorLog.Substring(compressedBuildSizeIdx+COMPRESSED_BUILD_SIZE_KEY.Length, compressedBuildSizeEndIdx - compressedBuildSizeIdx - COMPRESSED_BUILD_SIZE_KEY.Length);
            //Debug.Log("compressed: " + compressedBuildSize);
        }

        Array.Sort(buildSizes, delegate(BuildSizePart b1, BuildSizePart b2) {
            if (b1.Percentage > b2.Percentage) return -1;
            if (b1.Percentage < b2.Percentage) return 1;
            return 0;
        });

        buildType = GetBuildTypeFromEditorLog(editorLog);

        assetSizes = ParseAssetSizesFromEditorLog(editorLog, usedAssetsIdx+REPORT_START_KEY.Length);

        const string MONO_DLL_KEY = "Mono dependencies included in the build\n";
        int monoDllsStaIdx = editorLog.LastIndexOf(MONO_DLL_KEY, texturesIdx);
        int monoDllsEndIdx = editorLog.IndexOf("\n\n", monoDllsStaIdx);
        DLLs = editorLog.Substring(monoDllsStaIdx+MONO_DLL_KEY.Length, monoDllsEndIdx - monoDllsStaIdx-MONO_DLL_KEY.Length);
        //Debug.Log("STA\n" + monoDlls + "\nEND\n");
    }