| | 1 | | using System; |
| | 2 | | using DCL.Helpers; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using System.ComponentModel; |
| | 5 | | using System.IO; |
| | 6 | | using DCL.ABConverter; |
| | 7 | | using Unity.EditorCoroutines.Editor; |
| | 8 | | using UnityEditor; |
| | 9 | | using UnityEngine; |
| | 10 | | using UnityEngine.Networking; |
| | 11 | | using System.IO; |
| | 12 | | using System.Linq; |
| | 13 | | using UnityGLTF; |
| | 14 | | using static DCL.ContentServerUtils; |
| | 15 | | using Utils = DCL.Helpers.Utils; |
| | 16 | |
|
| | 17 | | namespace DCL.ABConverter |
| | 18 | | { |
| | 19 | | } |
| | 20 | |
|
| | 21 | | namespace DCL |
| | 22 | | { |
| | 23 | | public static class AssetBundleMenuItems |
| | 24 | | { |
| | 25 | | [System.Serializable] |
| | 26 | | public class EmptyParcels |
| | 27 | | { |
| | 28 | | public MappingPair[] EP_01; |
| | 29 | | public MappingPair[] EP_02; |
| | 30 | | public MappingPair[] EP_03; |
| | 31 | | public MappingPair[] EP_04; |
| | 32 | | public MappingPair[] EP_05; |
| | 33 | | public MappingPair[] EP_06; |
| | 34 | | public MappingPair[] EP_07; |
| | 35 | | public MappingPair[] EP_08; |
| | 36 | | public MappingPair[] EP_09; |
| | 37 | | public MappingPair[] EP_10; |
| | 38 | | public MappingPair[] EP_11; |
| | 39 | | public MappingPair[] EP_12; |
| | 40 | | } |
| | 41 | |
|
| | 42 | | private const string KERNEL_RELATIVE_PATH = "/../../../explorer/kernel"; // This has to be set manually accordin |
| | 43 | |
|
| | 44 | | [MenuItem("Decentraland/Asset Bundle Builder/Dump Default Empty Parcels")] |
| 0 | 45 | | public static void DumpEmptyParcels_Default() { DumpEmptyParcels(); } |
| | 46 | |
|
| | 47 | | [MenuItem("Decentraland/Asset Bundle Builder/Dump Halloween Empty Parcels")] |
| 0 | 48 | | public static void DumpEmptyParcels_Halloween() { DumpEmptyParcels("empty-scenes-halloween"); } |
| | 49 | |
|
| | 50 | | public static void DumpEmptyParcels(string folderName = "empty-scenes") |
| | 51 | | { |
| 0 | 52 | | string indexJsonPath = Application.dataPath; |
| | 53 | |
|
| 0 | 54 | | indexJsonPath += KERNEL_RELATIVE_PATH + $"/static/loader/{folderName}/index.json"; |
| | 55 | |
|
| 0 | 56 | | if (!File.Exists(indexJsonPath)) |
| | 57 | | { |
| 0 | 58 | | Debug.LogError("Index.json path doesn't exists! Make sure to 'make watch' first so it gets generated."); |
| 0 | 59 | | return; |
| | 60 | | } |
| | 61 | |
|
| 0 | 62 | | string emptyScenes = File.ReadAllText(indexJsonPath); |
| 0 | 63 | | var es = JsonUtility.FromJson<EmptyParcels>(emptyScenes); |
| | 64 | |
|
| 0 | 65 | | List<MappingPair> mappings = new List<MappingPair>(); |
| | 66 | |
|
| 0 | 67 | | mappings.AddRange(es.EP_01); |
| 0 | 68 | | mappings.AddRange(es.EP_02); |
| 0 | 69 | | mappings.AddRange(es.EP_03); |
| 0 | 70 | | mappings.AddRange(es.EP_04); |
| 0 | 71 | | mappings.AddRange(es.EP_05); |
| 0 | 72 | | mappings.AddRange(es.EP_06); |
| 0 | 73 | | mappings.AddRange(es.EP_07); |
| 0 | 74 | | mappings.AddRange(es.EP_08); |
| 0 | 75 | | mappings.AddRange(es.EP_09); |
| 0 | 76 | | mappings.AddRange(es.EP_10); |
| 0 | 77 | | mappings.AddRange(es.EP_11); |
| 0 | 78 | | mappings.AddRange(es.EP_12); |
| | 79 | |
|
| 0 | 80 | | string emptyScenesResourcesPath = Application.dataPath; |
| 0 | 81 | | emptyScenesResourcesPath += KERNEL_RELATIVE_PATH + $"/static/loader/{folderName}"; |
| | 82 | |
|
| 0 | 83 | | string customBaseUrl = "file://" + emptyScenesResourcesPath; |
| | 84 | |
|
| 0 | 85 | | var settings = new ABConverter.Client.Settings(ApiTLD.NONE); |
| 0 | 86 | | settings.skipAlreadyBuiltBundles = true; |
| 0 | 87 | | settings.deleteDownloadPathAfterFinished = false; |
| 0 | 88 | | settings.baseUrl = customBaseUrl + "/contents/"; |
| | 89 | |
|
| 0 | 90 | | var core = new ABConverter.Core(ABConverter.Environment.CreateWithDefaultImplementations(), settings); |
| 0 | 91 | | core.Convert(mappings.ToArray()); |
| 0 | 92 | | } |
| | 93 | |
|
| | 94 | | [MenuItem("Decentraland/Asset Bundle Builder/Dump All Body-Wearables")] |
| 0 | 95 | | public static void DumpAllBodiesWearables() { ABConverter.Client.DumpAllBodiesWearables(); } |
| | 96 | |
|
| | 97 | | [MenuItem("Decentraland/Asset Bundle Builder/Dump All Non-Body-Wearables (Optimized)")] |
| 0 | 98 | | public static void DumpAllNonBodiesWearables() { ABConverter.Client.DumpAllNonBodiesWearables(); } |
| | 99 | |
|
| | 100 | | [MenuItem("Decentraland/Start Visual Tests")] |
| 0 | 101 | | public static void StartVisualTests() { EditorCoroutineUtility.StartCoroutineOwnerless(VisualTests.TestConverted |
| | 102 | |
|
| | 103 | | [MenuItem("Decentraland/Asset Bundle Builder/Dump Org -110,-110")] |
| 0 | 104 | | public static void DumpArea() { ABConverter.Client.DumpArea(new Vector2Int(-110, -110), new Vector2Int(1, 1)); } |
| | 105 | |
|
| | 106 | | [MenuItem("Decentraland/Asset Bundle Builder/Dump scene QmXMzPLZNx5EHiYi3tK9MT5g9HqjAqgyAoZUu2LfAXJcSM")] |
| 0 | 107 | | public static void DumpSceneId() { ABConverter.Client.DumpScene("QmXMzPLZNx5EHiYi3tK9MT5g9HqjAqgyAoZUu2LfAXJcSM" |
| | 108 | |
|
| | 109 | | [MenuItem("Decentraland/Asset Bundle Builder/Dump Single Asset")] |
| | 110 | | public static void DumpSingleAsset() |
| | 111 | | { |
| | 112 | | // TODO: Make an editor window to setup these values from editor (for other dump-modes as well) |
| 0 | 113 | | ABConverter.Client.DumpAsset("QmS9eDwvcEpyYXChz6pFpyWyfyajiXbt6KA4CxQa3JKPGC", |
| | 114 | | "models/FloorBaseGrass_01/FloorBaseGrass_01.glb", |
| | 115 | | "QmXMzPLZNx5EHiYi3tK9MT5g9HqjAqgyAoZUu2LfAXJcSM"); |
| 0 | 116 | | } |
| | 117 | |
|
| | 118 | | [MenuItem("Decentraland/Asset Bundle Builder/Dump Org -6,30")] |
| 0 | 119 | | public static void DumpOrg() { ABConverter.Client.DumpArea(new Vector2Int(-6, 30), new Vector2Int(15, 15)); } |
| | 120 | |
|
| | 121 | | [MenuItem("Decentraland/Asset Bundle Builder/Dump Org 0,0")] |
| | 122 | | public static void DumpCenterPlaza() |
| | 123 | | { |
| 0 | 124 | | var zoneArray = Utils.GetCenteredZoneArray(new Vector2Int(0, 0), new Vector2Int(1, 1)); |
| 0 | 125 | | ABConverter.Client.DumpArea(zoneArray); |
| 0 | 126 | | } |
| | 127 | |
|
| | 128 | | [MenuItem("Decentraland/Asset Bundle Builder/Only Build Bundles")] |
| 0 | 129 | | public static void OnlyBuildBundles() { BuildPipeline.BuildAssetBundles(ABConverter.Config.ASSET_BUNDLES_PATH_RO |
| | 130 | | } |
| | 131 | | } |