|
4 | 4 |
|
5 | 5 | public class BuildAssetBundles |
6 | 6 | { |
7 | | - [MenuItem ("Tools/Generate Test Data")] |
8 | | - static void GenerateTestData () |
| 7 | + [MenuItem ("Tools/Generate AssetBundles")] |
| 8 | + static void GenerateAssetBundles () |
9 | 9 | { |
10 | 10 | Directory.CreateDirectory("AssetBundles"); |
11 | 11 |
|
12 | 12 | BuildPipeline.BuildAssetBundles ("AssetBundles", BuildAssetBundleOptions.None, BuildTarget.StandaloneOSX); |
13 | | - |
14 | | - CopyTo("TestCommon"); |
15 | 13 |
|
16 | | - string[] levels = new string[] {"Assets/Scenes/OtherScene.unity"}; |
17 | | - BuildPipeline.BuildPlayer(levels, Path.Combine(Path.GetDirectoryName(Application.dataPath), "build", "game"), BuildTarget.StandaloneOSX, BuildOptions.None); |
18 | | - var outPath = Path.Combine(Directory.GetParent(Application.dataPath).Parent.FullName, "TestCommon", "data", |
19 | | - "PlayerData"); |
| 14 | + var outPath = Path.Combine(Directory.GetParent(Application.dataPath).Parent.FullName, "TestCommon", "Data", "AssetBundles", Application.unityVersion); |
| 15 | + |
20 | 16 | Directory.CreateDirectory(outPath); |
21 | | - File.Copy(Path.Combine("build", "game.app", "Contents", "Resources", "Data", "level0"), outPath, true); |
| 17 | + File.Copy(Path.Combine("AssetBundles", "assetbundle"), Path.Combine(outPath, "assetbundle"), true); |
| 18 | + File.Copy(Path.Combine("AssetBundles", "scenes"), Path.Combine(outPath, "scenes"), true); |
22 | 19 | } |
23 | | - |
24 | | - static void CopyTo(string project) |
| 20 | + |
| 21 | + [MenuItem ("Tools/Generate PlayerData")] |
| 22 | + static void GeneratePlayerData () |
25 | 23 | { |
26 | | - var outPath = Path.Combine(Directory.GetParent(Application.dataPath).Parent.FullName, project, "data", Application.unityVersion, "AssetBundles"); |
27 | | - Directory.CreateDirectory(outPath); |
| 24 | + if (!EditorUtility.DisplayDialog("Warning!", |
| 25 | + "Make sure that the \"ForceAlwaysWriteTypeTrees\" Diagnostic Switch is enabled in the Editor Preferences (Diagnostic/Editor section)", |
| 26 | + "OK", "Wait, let me do it!")) |
| 27 | + { |
| 28 | + return; |
| 29 | + } |
28 | 30 |
|
29 | | - File.Copy(Path.Combine("AssetBundles", "assetbundle"), Path.Combine(outPath, "assetbundle"), true); |
30 | | - File.Copy(Path.Combine("AssetBundles", "scenes"), Path.Combine(outPath, "scenes"), true); |
| 31 | + string[] levels = new string[] {"Assets/Scenes/OtherScene.unity"}; |
| 32 | + BuildPipeline.BuildPlayer(levels, Path.Combine(Path.GetDirectoryName(Application.dataPath), "build", "game"), BuildTarget.StandaloneOSX, BuildOptions.None); |
| 33 | + |
| 34 | + var outPath = Path.Combine(Directory.GetParent(Application.dataPath).Parent.FullName, "TestCommon", "Data", "PlayerData", Application.unityVersion); |
| 35 | + |
| 36 | + Directory.CreateDirectory(outPath); |
| 37 | + File.Copy(Path.Combine("build", "game.app", "Contents", "Resources", "Data", "level0"), outPath, true); |
31 | 38 | } |
32 | 39 | } |
0 commit comments