var scenes = GetScenes(); BuildTarget target; #if UNITY_EDITOR_WIN target = BuildTarget.StandaloneWindows; #else target = BuildTarget.StandaloneOSXIntel; #endif for (var i = 0; i < scenes.Length; i++) { var name = GetSceneName(scenes[i]); string errorMessage = BuildPipeline.BuildPlayer( newstring[] { scenes[i] }, outputPath + name + ".exe", // 出力先 target, // ビルド対象プラットフォーム BuildOptions.Development // ビルドオプション ); Debug.Log(i + ":build " + name); var log = AnalyzeLog(); StreamWriter writer = new StreamWriter(outputPath + name + ".log"); writer.WriteLine(log); writer.Close(); } }
//シーンのパスからシーン名だけを取得する staticstringGetSceneName(string path) { var a = path.LastIndexOf("/"); var b = path.LastIndexOf("."); return path.Substring(a + 1, b - a - 1); }
//ビルド対象のシーン一覧を取得する staticstring[] GetScenes() { List<string> sceneList = new List<string>();
EditorBuildSettingsScene[] scenes = EditorBuildSettings.scenes; foreach (EditorBuildSettingsScene scene in scenes) { sceneList.Add(scene.path); } return sceneList.ToArray(); }
//ログファイルを解析し、容量部分だけを抽出する publicstaticstringAnalyzeLog() { string logPath; #if UNITY_EDITOR_WIN logPath = @"C:\Users\" + Environment.UserName + @"\AppData\Local\Unity\Editor\Editor.log"; #else logPath = "~/Library/Logs/Unity/Editor.log"; #endif FileStream fs = new FileStream(logPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); StreamReader sr = new StreamReader(fs); string text = sr.ReadToEnd(); sr.Close(); fs.Close(); var matches = new Regex(@"Build Report\s[\s\S]*?-------------------").Matches(text); if (matches.Count <= 0) { Debug.LogError("No Log"); returnnull; } return matches[matches.Count - 1].ToString();
Used Assets and files from the Resources folder, sorted by uncompressed size: 4.5 mb 9.1% Assets/Mech/PostProcessing/Resources/Shaders/Uber.shader 3.1 mb 6.4% Assets/Fungus/Textures/DialogBoxSliced.png 2.2 mb 4.5% Assets/Fungus/Resources/Sprites/Background.png