void CreateCustomAssetPacks(AddressableAssetSettings settings, CustomAssetPackSettings customAssetPackSettings, bool resetAssetPackSchemaData)
        {
            List <CustomAssetPackEditorInfo> customAssetPacks = customAssetPackSettings.CustomAssetPacks;
            var assetPackToDataEntry      = new Dictionary <string, CustomAssetPackDataEntry>();
            var bundleIdToEditorDataEntry = new Dictionary <string, BuildProcessorDataEntry>();

            CreateBuildOutputFolders();

            foreach (AddressableAssetGroup group in settings.groups)
            {
                if (HasRequiredSchemas(settings, group))
                {
                    var assetPackSchema = group.GetSchema <PlayAssetDeliverySchema>();
                    // Reset schema data to match Custom Asset Pack Settings. This can occur when the CustomAssetPackSettings was deleted but the schema properties still use the old settings data.
                    if (resetAssetPackSchemaData || assetPackSchema.AssetPackIndex >= customAssetPacks.Count)
                    {
                        assetPackSchema.ResetAssetPackIndex();
                    }

                    CustomAssetPackEditorInfo assetPack = customAssetPacks[assetPackSchema.AssetPackIndex];
                    if (IsAssignedToCustomAssetPack(settings, group, assetPackSchema, assetPack))
                    {
                        CreateConfigFiles(group, assetPack.AssetPackName, assetPack.DeliveryType, assetPackToDataEntry, bundleIdToEditorDataEntry);
                    }
                }
            }

            // Create the bundleIdToEditorDataEntry. It contains information for relocating custom asset pack bundles when building a player.
            SerializeBuildProcessorData(bundleIdToEditorDataEntry.Values.ToList());

            // Create the CustomAssetPacksData.json file. It contains all custom asset pack information that can be used at runtime.
            SerializeCustomAssetPacksData(assetPackToDataEntry.Values.ToList());
        }
Exemplo n.º 2
0
        void OnEnable()
        {
            m_Settings = target as CustomAssetPackSettings;
            if (m_Settings == null)
            {
                return;
            }

            m_CustomAssetPacks = new ReorderableList(m_Settings.CustomAssetPacks, typeof(CustomAssetPackEditorInfo), true, true, true, true);
            m_CustomAssetPacks.drawElementCallback = DrawCustomAssetPackCallback;
            m_CustomAssetPacks.headerHeight        = 0;
            m_CustomAssetPacks.onAddCallback       = OnAddCustomAssetPack;
            m_CustomAssetPacks.onRemoveCallback    = OnRemoveCustomAssetPack;
        }
        protected override TResult DoBuild <TResult>(AddressablesDataBuilderInput builderInput, AddressableAssetsBuildContext aaContext)
        {
            // Build AssetBundles
            TResult result = base.DoBuild <TResult>(builderInput, aaContext);

            // Don't prepare content for asset packs if the build target isn't set to Android
            if (builderInput.Target != BuildTarget.Android)
            {
                Addressables.LogWarning("Build target is not set to Android. No custom asset pack config files will be created.");
                return(result);
            }

            var resetAssetPackSchemaData = !CustomAssetPackSettings.SettingsExists;
            var customAssetPackSettings  = CustomAssetPackSettings.GetSettings(true);

            CreateCustomAssetPacks(aaContext.Settings, customAssetPackSettings, resetAssetPackSchemaData);
            return(result);
        }
 public void ResetAssetPackIndex()
 {
     AssetPackIndex = 0;
     m_Settings     = null;
 }