Beispiel #1
0
        public void DefaultBuildTasks_GenerateBundleMaps()
        {
            IDependencyData  dep       = GetDependencyData();
            IBundleWriteData writeData = new BundleWriteData();

            ReturnCode exitCode = RunTask <GenerateBundleMaps>(dep, writeData);

            Assert.AreEqual(ReturnCode.Success, exitCode);
        }
Beispiel #2
0
        public void DefaultBuildTasks_GenerateBundlePacking()
        {
            IBundleBuildContent       buildContent    = GetBundleContent();
            IDependencyData           dep             = GetDependencyData();
            IBundleWriteData          writeData       = new BundleWriteData();
            IDeterministicIdentifiers deterministicId = new PrefabPackedIdentifiers();

            ReturnCode exitCode = RunTask <GenerateBundlePacking>(buildContent, dep, writeData, deterministicId);

            Assert.AreEqual(ReturnCode.Success, exitCode);
        }
        public void SetAssetEntriesBundleFileIdToCatalogEntryBundleFileId_SetsBundleFileIdToBundleNameOnly_WhenGroupSchemaNamingIsSetToFilename()
        {
            //Setup
            GUID   entry1Guid         = GUID.Generate();
            string bundleFile         = "bundle";
            string internalBundleName = "bundlepath";
            string finalBundleName    = "finalBundlePath";
            string bundleCatalogEntryInternalIdHashed   = "catalogentrybundlefileid_1234567890.bundle";
            string bundleCatalogEntryInternalIdUnHashed = "catalogentrybundlefileid.bundle";

            AddressableAssetEntry entry1 = new AddressableAssetEntry(entry1Guid.ToString(), "123", null, false);
            AddressableAssetGroup group  = Settings.CreateGroup("testGroup", false, false, false,
                                                                new List <AddressableAssetGroupSchema>(), typeof(BundledAssetGroupSchema));

            group.GetSchema <BundledAssetGroupSchema>().BundleNaming = BundledAssetGroupSchema.BundleNamingStyle.NoHash;
            group.AddAssetEntry(entry1, false);

            ICollection <AddressableAssetEntry> entries = new List <AddressableAssetEntry>()
            {
                entry1
            };

            Dictionary <string, string> bundleToIdMap = new Dictionary <string, string>()
            {
                { internalBundleName, finalBundleName }
            };

            IBundleWriteData writeData = new BundleWriteData();

            writeData.AssetToFiles.Add(entry1Guid, new List <string>()
            {
                bundleFile
            });
            writeData.FileToBundle.Add(bundleFile, internalBundleName);

            Dictionary <string, ContentCatalogDataEntry> catalogMap = new Dictionary <string, ContentCatalogDataEntry>()
            {
                {
                    finalBundleName,
                    new ContentCatalogDataEntry(typeof(IAssetBundleResource), bundleCatalogEntryInternalIdHashed,
                                                typeof(AssetBundleProvider).FullName, new[] { "catalogentry" })
                }
            };

            //Test
            BuildScriptPackedMode.SetAssetEntriesBundleFileIdToCatalogEntryBundleFileId(entries, bundleToIdMap, writeData, catalogMap);

            //Assert
            Assert.AreEqual(bundleCatalogEntryInternalIdUnHashed, entry1.BundleFileId);

            //Cleanup
            Settings.RemoveGroup(group);
        }
        public void SetAssetEntriesBundleFileIdToCatalogEntryBundleFileId_ModifiedOnlyAssetEntries_ThatAreIncludedInBuildWriteData()
        {
            GUID   entry1Guid                   = GUID.Generate();
            GUID   entry2Guid                   = GUID.Generate();
            string bundleFile                   = "bundle";
            string internalBundleName           = "bundlepath";
            string finalBundleName              = "finalBundlePath";
            string bundleCatalogEntryInternalId = "catalogentrybundlefileid";

            AddressableAssetEntry entry1 = new AddressableAssetEntry(entry1Guid.ToString(), "123", null, false);
            AddressableAssetEntry entry2 = new AddressableAssetEntry(entry2Guid.ToString(), "456", null, false);
            ICollection <AddressableAssetEntry> entries = new List <AddressableAssetEntry>()
            {
                entry1, entry2
            };

            Dictionary <string, string> bundleToIdMap = new Dictionary <string, string>()
            {
                { internalBundleName, finalBundleName }
            };

            IBundleWriteData writeData = new BundleWriteData();

            writeData.AssetToFiles.Add(entry1Guid, new List <string>()
            {
                bundleFile
            });
            writeData.FileToBundle.Add(bundleFile, internalBundleName);

            Dictionary <string, ContentCatalogDataEntry> catalogMap = new Dictionary <string, ContentCatalogDataEntry>()
            {
                {
                    finalBundleName,
                    new ContentCatalogDataEntry(typeof(IAssetBundleResource), bundleCatalogEntryInternalId,
                                                typeof(AssetBundleProvider).FullName, new[] { "catalogentry" })
                }
            };

            BuildScriptPackedMode.SetAssetEntriesBundleFileIdToCatalogEntryBundleFileId(entries, bundleToIdMap, writeData, catalogMap);

            Assert.AreEqual(bundleCatalogEntryInternalId, entry1.BundleFileId);
            Assert.IsNull(entry2.BundleFileId);
        }
Beispiel #5
0
        public void DefaultBuildTasks_PostPackingCallback()
        {
            bool packingCallbackCalled = false;

            IBuildParameters buildParams = GetBuildParameters();
            IDependencyData  dep         = GetDependencyData();
            IBundleWriteData writeData   = new BundleWriteData();
            BuildCallbacks   callback    = new BuildCallbacks();

            callback.PostPackingCallback = (parameters, data, arg3) =>
            {
                packingCallbackCalled = true;
                return(ReturnCode.Success);
            };

            ReturnCode exitCode = RunTask <PostPackingCallback>(buildParams, dep, writeData, callback);

            Assert.AreEqual(ReturnCode.Success, exitCode);
            Assert.IsTrue(packingCallbackCalled);
        }
Beispiel #6
0
        private ContentUpdateScript.ContentUpdateContext GetContentUpdateContext(string contentUpdateTestAssetGUID, string contentUpdateTestCachedAssetHash,
                                                                                 string contentUpdateTestNewInternalBundleName, string contentUpdateTestNewBundleName, string contentUpdateTestCachedBundlePath, string contentUpdateTestGroupGuid, string contentUpdateTestFileName)
        {
            Dictionary <string, string> bundleToInternalBundle = new Dictionary <string, string>()
            {
                {
                    contentUpdateTestNewInternalBundleName,
                    contentUpdateTestNewBundleName
                }
            };

            Dictionary <string, CachedAssetState> guidToCachedState = new Dictionary <string, CachedAssetState>()
            {
                //entry 1
                {
                    contentUpdateTestAssetGUID, new CachedAssetState()
                    {
                        bundleFileId = contentUpdateTestCachedBundlePath,
                        asset        = new AssetState()
                        {
                            guid = new GUID(contentUpdateTestAssetGUID),
                            hash = Hash128.Parse(contentUpdateTestCachedAssetHash)
                        },
                        dependencies = new AssetState[] { },
                        data         = null,
                        groupGuid    = contentUpdateTestGroupGuid
                    }
                }
            };

            Dictionary <string, ContentCatalogDataEntry> idToCatalogEntryMap = new Dictionary <string, ContentCatalogDataEntry>()
            {
                //bundle entry
                { contentUpdateTestNewBundleName,
                  new ContentCatalogDataEntry(typeof(IAssetBundleResource), contentUpdateTestNewBundleName,
                                              typeof(AssetBundleProvider).FullName, new [] { contentUpdateTestNewBundleName }) },
                //asset entry
                {
                    contentUpdateTestAssetGUID,
                    new ContentCatalogDataEntry(typeof(IResourceLocation), contentUpdateTestAssetGUID, typeof(BundledAssetProvider).FullName, new [] { contentUpdateTestAssetGUID })
                }
            };

            IBundleWriteData writeData = new BundleWriteData();

            writeData.AssetToFiles.Add(new GUID(contentUpdateTestAssetGUID), new List <string>()
            {
                contentUpdateTestFileName
            });
            writeData.FileToBundle.Add(contentUpdateTestFileName, contentUpdateTestNewInternalBundleName);

            ContentUpdateScript.ContentUpdateContext context = new ContentUpdateScript.ContentUpdateContext()
            {
                WriteData = writeData,
                BundleToInternalBundleIdMap = bundleToInternalBundle,
                GuidToPreviousAssetStateMap = guidToCachedState,
                IdToCatalogDataEntryMap     = idToCatalogEntryMap,
                ContentState = new AddressablesContentState(),
                PreviousAssetStateCarryOver = new List <CachedAssetState>(),
                Registry = new FileRegistry()
            };
            return(context);
        }