Пример #1
0
    public static void BuildContentUpdate()
    {
        var buildPath = ContentUpdateScript.GetContentStateDataPath(false);
        var settings  = AddressableAssetSettingsDefaultObject.Settings;

        ContentUpdateScript.BuildContentUpdate(settings, buildPath);
    }
Пример #2
0
        public static void UpdateGroups()
        {
            string statePath = "Artifacts/addressables_content_state.bin";
            List <AddressableAssetEntry> entries = ContentUpdateScript.GatherModifiedEntries(AddressableAssetSettingsDefaultObject.Settings, statePath);

            ContentUpdateScript.CreateContentUpdateGroup(AddressableAssetSettingsDefaultObject.Settings, entries, "Update Group");
        }
        public static string Build()
        {
            RefreshAssetsList();

            var path = ContentUpdateScript.GetContentStateDataPath(false);
            var res  = "";

            if (File.Exists(path))
            {
                // すでにStateDataがあれば、ContentUpdate(差分)ビルドします
                var result = ContentUpdateScript.BuildContentUpdate(AddressableAssetSettingsDefaultObject.Settings, path);
                if (result != null)
                {
                    res = result.Error;
                }
                else
                {
                    // エラーが発生したため、初回ビルドとして処理する
                    AddressableAssetSettings.BuildPlayerContent();
                    Debug.Log("BuildContentUpdate Error:初回ビルドで処理する");
                }
            }
            else
            {
                // StateDataがなければ、初回ビルドする
                AddressableAssetSettings.BuildPlayerContent();
            }
            return(res);
        }
Пример #4
0
    public static void CheckForUpdateContent()
    {
        //与上次打包做资源对比
        string buildPath  = ContentUpdateScript.GetContentStateDataPath(false);
        var    m_Settings = AddressableAssetSettingsDefaultObject.Settings;
        List <AddressableAssetEntry> entrys = ContentUpdateScript.GatherModifiedEntries(m_Settings, buildPath);

        if (entrys.Count == 0)
        {
            Debug.Log("没有资源变更");
            return;
        }
        StringBuilder sbuider = new StringBuilder();

        sbuider.AppendLine("Need Update Assets:");
        foreach (var _ in entrys)
        {
            sbuider.AppendLine(_.address);
        }
        Debug.Log(sbuider.ToString());
        //将被修改过的资源单独分组---可以自定义组名
        var groupName = string.Format("UpdateGroup_{0}", DateTime.Now.ToString("yyyyMMddHHmmss"));

        ContentUpdateScript.CreateContentUpdateGroup(m_Settings, entrys, groupName);
    }
Пример #5
0
        public void ContentUpdateScenes_PackedTogetherByLabel_MarksAllScenesModifiedWithSharedLabel()
        {
            AddressableAssetGroup group = Settings.CreateGroup("SceneGroup", false, false, false, null, typeof(BundledAssetGroupSchema));

            group.GetSchema <BundledAssetGroupSchema>().BundleMode = BundledAssetGroupSchema.BundlePackingMode.PackTogetherByLabel;

            AddressableAssetEntry scene1 = new AddressableAssetEntry(m_SceneGuids[0], "scene1", group, false);
            AddressableAssetEntry scene2 = new AddressableAssetEntry(m_SceneGuids[1], "scene2", group, false);
            AddressableAssetEntry scene3 = new AddressableAssetEntry(m_SceneGuids[2], "scene3", group, false);

            group.AddAssetEntry(scene1, false);
            group.AddAssetEntry(scene2, false);
            group.AddAssetEntry(scene3, false);

            scene1.SetLabel("label", true);
            scene3.SetLabel("label", true);

            List <AddressableAssetEntry> modifedEnteries = new List <AddressableAssetEntry>()
            {
                scene1
            };

            ContentUpdateScript.AddAllDependentScenesFromModifiedEnteries(modifedEnteries);

            Assert.AreEqual(2, modifedEnteries.Count);
            Assert.AreEqual(scene1, modifedEnteries[0]);
            Assert.AreEqual(scene3, modifedEnteries[1]);

            Settings.RemoveGroup(group);
        }
Пример #6
0
        public void ContentUpdateScenes_PackedSeperately_MarksNoAdditionalScenes()
        {
            AddressableAssetGroup group = Settings.CreateGroup("SceneGroup", false, false, false, null, typeof(BundledAssetGroupSchema));

            group.GetSchema <BundledAssetGroupSchema>().BundleMode = BundledAssetGroupSchema.BundlePackingMode.PackSeparately;

            AddressableAssetEntry scene1 = new AddressableAssetEntry(m_SceneGuids[0], "scene1", group, false);
            AddressableAssetEntry scene2 = new AddressableAssetEntry(m_SceneGuids[1], "scene2", group, false);
            AddressableAssetEntry scene3 = new AddressableAssetEntry(m_SceneGuids[2], "scene3", group, false);

            group.AddAssetEntry(scene1, false);
            group.AddAssetEntry(scene2, false);
            group.AddAssetEntry(scene3, false);

            List <AddressableAssetEntry> modifedEnteries = new List <AddressableAssetEntry>()
            {
                scene1
            };

            ContentUpdateScript.AddAllDependentScenesFromModifiedEnteries(modifedEnteries);

            Assert.AreEqual(1, modifedEnteries.Count);
            Assert.AreEqual(scene1, modifedEnteries[0]);

            Settings.RemoveGroup(group);
        }
Пример #7
0
        public void BuildContentUpdate()
        {
            var group = Settings.CreateGroup("LocalStuff3", false, false, false, null);

            Settings.BuildRemoteCatalog     = true;
            Settings.RemoteCatalogBuildPath = new ProfileValueReference();
            Settings.RemoteCatalogBuildPath.SetVariableByName(Settings, AddressableAssetSettings.kRemoteBuildPath);
            Settings.RemoteCatalogLoadPath = new ProfileValueReference();
            Settings.RemoteCatalogLoadPath.SetVariableByName(Settings, AddressableAssetSettings.kRemoteLoadPath);
            var schema = group.AddSchema <BundledAssetGroupSchema>();

            schema.BuildPath.SetVariableByName(Settings, AddressableAssetSettings.kLocalBuildPath);
            schema.LoadPath.SetVariableByName(Settings, AddressableAssetSettings.kLocalLoadPath);
            schema.BundleMode = BundledAssetGroupSchema.BundlePackingMode.PackTogether;
            group.AddSchema <ContentUpdateGroupSchema>().StaticContent = true;
            Settings.CreateOrMoveEntry(m_AssetGUID, group);
            var context = new AddressablesDataBuilderInput(Settings);

            var op = Settings.ActivePlayerDataBuilder.BuildData <AddressablesPlayerBuildResult>(context);

            Assert.IsTrue(string.IsNullOrEmpty(op.Error), op.Error);
            var tempPath = Path.GetDirectoryName(Application.dataPath) + "/Library/com.unity.addressables/StreamingAssetsCopy/" + PlatformMappingService.GetPlatform() + "/addressables_content_state.bin";
            var buildOp  = ContentUpdateScript.BuildContentUpdate(Settings, tempPath);

            Assert.IsNotNull(buildOp);
            Assert.IsTrue(string.IsNullOrEmpty(buildOp.Error));
        }
    public static void BuildUpdate()
    {
        CreateVersionBuild.CreateVersion();
        SetDataBuilder();
        string path = ContentUpdateScript.GetContentStateDataPath(false);

        ContentUpdateScript.BuildContentUpdate(AddressableAssetSettingsDefaultObject.Settings, path);
    }
Пример #9
0
        internal static bool PrepareForContentUpdate(AddressableAssetSettings settings, string buildPath)
        {
            var modifiedEntries = ContentUpdateScript.GatherModifiedEntriesWithDependencies(settings, buildPath);
            var previewWindow   = GetWindow <ContentUpdatePreviewWindow>();

            previewWindow.Show(settings, modifiedEntries);
            return(true);
        }
Пример #10
0
    public static void BuildUpdate()
    {
        var path       = ContentUpdateScript.GetContentStateDataPath(false);
        var m_Settings = AddressableAssetSettingsDefaultObject.Settings;
        AddressablesPlayerBuildResult result = ContentUpdateScript.BuildContentUpdate(AddressableAssetSettingsDefaultObject.Settings, path);

        Debug.Log("BuildFinish path = " + m_Settings.RemoteCatalogBuildPath.GetValue(m_Settings));
    }
Пример #11
0
        public void IsCacheDataValid_WhenNoPreviousRemoteCatalogPath_ReturnsFalseWithError()
        {
            AddressablesContentState cacheData = new AddressablesContentState();

            cacheData.editorVersion = Application.unityVersion;
            Assert.IsFalse(ContentUpdateScript.IsCacheDataValid(Settings, cacheData));
            LogAssert.Expect(LogType.Error, new Regex("Previous build had 'Build Remote Catalog' disabled.*"));
        }
Пример #12
0
        public void OnGUI()
        {
            if (m_DepEntriesMap == null)
            {
                return;
            }
            Rect contentRect = new Rect(0, 0, position.width, position.height - 50);

            if (m_Tree == null)
            {
                if (m_TreeState == null)
                {
                    m_TreeState = new TreeViewState();
                }

                var headerState = ContentUpdateTreeView.CreateDefaultMultiColumnHeaderState();
                if (MultiColumnHeaderState.CanOverwriteSerializedFields(m_Mchs, headerState))
                {
                    MultiColumnHeaderState.OverwriteSerializedFields(m_Mchs, headerState);
                }
                m_Mchs = headerState;

                m_Tree = new ContentUpdateTreeView(this, m_TreeState, m_Mchs);
                m_Tree.Reload();
            }

            if (m_DepEntriesMap.Count == 0)
            {
                GUILayout.BeginArea(contentRect);
                GUILayout.BeginVertical();

                GUILayout.Label("No Addressable groups with a BundledAssetGroupSchema and ContentUpdateGroupSchema (with StaticContent enabled) appear to have been modified.");

                GUILayout.EndVertical();
                GUILayout.EndArea();
            }
            else
            {
                m_Tree.OnGUI(contentRect);
            }

            GUILayout.BeginArea(new Rect(0, position.height - 50, position.width, 50));
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Cancel"))
            {
                Close();
            }
            using (new EditorGUI.DisabledScope(m_Tree.GetEnabledEntries().Count == 0))
            {
                if (GUILayout.Button("Apply Changes"))
                {
                    ContentUpdateScript.CreateContentUpdateGroup(m_Settings, m_Tree.GetEnabledEntries(), "Content Update");
                    Close();
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.EndArea();
        }
Пример #13
0
        void OnPrepareUpdate()
        {
            var path = ContentUpdateScript.GetContentStateDataPath(true);

            if (!string.IsNullOrEmpty(path))
            {
                ContentUpdatePreviewWindow.PrepareForContentUpdate(AddressableAssetSettingsDefaultObject.Settings, path);
            }
        }
Пример #14
0
        public override void Build(BuildTarget target,
                                   Model.NodeData node,
                                   IEnumerable <PerformGraph.AssetGroups> incoming,
                                   IEnumerable <Model.ConnectionData> connectionsToOutput,
                                   PerformGraph.Output Output,
                                   Action <Model.NodeData, string, float> progressFunc)
        {
            var updatePerformed = false;

            if (!string.IsNullOrEmpty(m_profileName) && m_profileName != kCurrentProfile)
            {
                Settings.activeProfileId = AddressableAssetSettingsDefaultObject.Settings.profileSettings.GetProfileId(m_profileName);
                //AddressableAssetSettingsDefaultObject.Settings.activeProfileId = AddressableAssetSettingsDefaultObject.Settings.profileSettings.GetProfileId(m_profileName);
            }

            if (m_preferUpdate)
            {
                if (string.IsNullOrEmpty(m_contentStateFilePath) || !File.Exists(m_contentStateFilePath))
                {
                    m_contentStateFilePath = ContentUpdateScript.GetContentStateDataPath(false);
                }

                if (!string.IsNullOrEmpty(m_contentStateFilePath) && File.Exists(m_contentStateFilePath))
                {
                    ContentUpdateScript.BuildContentUpdate(AddressableAssetSettingsDefaultObject.Settings, m_contentStateFilePath);
                    updatePerformed = true;
                }
            }

            if (!updatePerformed)
            {
                var index = Settings.DataBuilders.IndexOf(m_currentDataBuilder);

                AddressableAssetSettingsDefaultObject.Settings.ActivePlayerDataBuilderIndex = index;
                AddressableAssetSettings.BuildPlayerContent();
            }

            // AddressableBuilder does not add, filter or change structure of group, so just pass given group of assets
            if (Output != null)
            {
                var dst = (connectionsToOutput == null || !connectionsToOutput.Any())
                                        ? null
                                        : connectionsToOutput.First();

                if (incoming != null)
                {
                    foreach (var ag in incoming)
                    {
                        Output(dst, ag.assetGroups);
                    }
                }
                else
                {
                    Output(dst, new Dictionary <string, List <AssetReference> >());
                }
            }
        }
Пример #15
0
        private void PostProcessCatalogEnteries(AddressableAssetGroup group, IBundleWriteData writeData, List <ContentCatalogDataEntry> locations, FileRegistry fileRegistry)
        {
            if (!group.HasSchema <BundledAssetGroupSchema>() || !File.Exists(ContentUpdateScript.GetContentStateDataPath(false)))
            {
                return;
            }

            AddressablesContentState contentState = ContentUpdateScript.LoadContentState(ContentUpdateScript.GetContentStateDataPath(false));

            foreach (AddressableAssetEntry entry in group.entries)
            {
                CachedAssetState cachedAsset = contentState.cachedInfos.FirstOrDefault(i => i.asset.guid.ToString() == entry.guid);
                if (cachedAsset != null)
                {
                    if (entry.parentGroup.Guid == cachedAsset.groupGuid)
                    {
                        GUID guid = new GUID(entry.guid);
                        if (!writeData.AssetToFiles.ContainsKey(guid))
                        {
                            continue;
                        }

                        string file           = writeData.AssetToFiles[guid][0];
                        string fullBundleName = writeData.FileToBundle[file];

                        ContentCatalogDataEntry catalogBundleEntry = locations.FirstOrDefault((loc) => (loc.Keys[0] as string) == fullBundleName);

                        if (catalogBundleEntry != null)
                        {
                            if (String.IsNullOrEmpty(entry.BundleFileId))
                            {
                                entry.BundleFileId = catalogBundleEntry.InternalId;
                            }
                            else
                            {
                                if (catalogBundleEntry.InternalId != cachedAsset.bundleFileId)
                                {
                                    string unusedBundlePath =
                                        fileRegistry.GetFilePathForBundle(
                                            Path.GetFileNameWithoutExtension(fullBundleName));

                                    if (File.Exists(unusedBundlePath) &&
                                        fileRegistry.ReplaceBundleEntry(
                                            Path.GetFileNameWithoutExtension(fullBundleName),
                                            cachedAsset.bundleFileId))
                                    {
                                        File.Delete(unusedBundlePath);
                                        catalogBundleEntry.InternalId = entry.BundleFileId;
                                        catalogBundleEntry.Data       = cachedAsset.data;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #16
0
        public void IsCacheDataValid_WhenMismatchedEditorVersions_LogsWarning()
        {
            AddressablesContentState cacheData = new AddressablesContentState();

            cacheData.editorVersion = "invalid";
            Assert.IsFalse(ContentUpdateScript.IsCacheDataValid(Settings, cacheData));
            LogAssert.Expect(LogType.Warning, new Regex(".*with version `" + cacheData.editorVersion + "`.*"));
            LogAssert.Expect(LogType.Error, new Regex("Previous.*"));
        }
        void OnUpdateBuild()
        {
            var path = ContentUpdateScript.GetContentStateDataPath(true);

            if (!string.IsNullOrEmpty(path))
            {
                ContentUpdateScript.BuildContentUpdate(AddressableAssetSettingsDefaultObject.Settings, path);
            }
        }
        /// <summary>
        /// Opens ContentUpdatePreviewWindow.
        /// </summary>
        /// <param name="settings"></param>
        /// <param name="buildPath"></param>
        /// <returns>True if successful; false if otherwise (failed to get modified entries).</returns>
        public static bool PrepareForContentUpdate(AddressableAssetSettings settings, string buildPath)
        {
            var modifiedEntries = ContentUpdateScript.GatherModifiedEntries(settings, buildPath);

            if (modifiedEntries == null)
            {
                return(false);
            }
            var previewWindow = GetWindow <ContentUpdatePreviewWindow>();

            previewWindow.Show(settings, modifiedEntries);
            return(true);
        }
Пример #19
0
        public void IsCacheDataValid_WhenMismatchedCatalogPaths_ReturnsFalseWithError()
        {
            AddressablesContentState cacheData = new AddressablesContentState();

            cacheData.editorVersion         = Application.unityVersion;
            cacheData.remoteCatalogLoadPath = "somePath";
            var oldSetting = Settings.BuildRemoteCatalog;

            Settings.BuildRemoteCatalog = true;
            Assert.IsFalse(ContentUpdateScript.IsCacheDataValid(Settings, cacheData));
            LogAssert.Expect(LogType.Error, new Regex("Current 'Remote Catalog Load Path' does not match load path of original player.*"));
            Settings.BuildRemoteCatalog = oldSetting;
        }
Пример #20
0
        public void IsCacheDataValid_WhenRemoteCatalogDisabled_ReturnsFalseWithError()
        {
            AddressablesContentState cacheData = new AddressablesContentState();

            cacheData.editorVersion         = Application.unityVersion;
            cacheData.remoteCatalogLoadPath = "somePath";
            var oldSetting = Settings.BuildRemoteCatalog;

            Settings.BuildRemoteCatalog = false;
            Assert.IsFalse(ContentUpdateScript.IsCacheDataValid(Settings, cacheData));
            LogAssert.Expect(LogType.Error, new Regex("Current settings have 'Build Remote Catalog' disabled.*"));
            Settings.BuildRemoteCatalog = oldSetting;
        }
Пример #21
0
    private static void PerformAddressablesContentUpdate()
    {
        string contentStateDataPath = ContentUpdateScript.GetContentStateDataPath(false);

        if (!File.Exists(contentStateDataPath))
        {
            throw new Exception("Previous Content State Data missing");
        }

        AddressableAssetSettings settings = AddressableAssetSettingsDefaultObject.Settings;

        ContentUpdateScript.BuildContentUpdate(settings, contentStateDataPath);
    }
Пример #22
0
        public void  GetStaticContentDependenciesOfModifiedEntries_DoesNotFlagEntryDependencies_WithStaticContentDisabled()
        {
            var mainAssetGroup = Settings.CreateGroup("MainAssetGroup", false, false, false, null,
                                                      typeof(ContentUpdateGroupSchema), typeof(BundledAssetGroupSchema));

            var dynamicContentGroup = Settings.CreateGroup("DynamicContentGroup", false, false, false, null,
                                                           typeof(ContentUpdateGroupSchema), typeof(BundledAssetGroupSchema));

            mainAssetGroup.GetSchema <ContentUpdateGroupSchema>().StaticContent      = true;
            dynamicContentGroup.GetSchema <ContentUpdateGroupSchema>().StaticContent = false;

            GameObject mainObject = new GameObject("mainObject");
            Material   mat        = new Material(Shader.Find("Transparent/Diffuse"));

            mainObject.AddComponent <MeshRenderer>().material = mat;

            string mainAssetPath    = Path.Combine(k_TestConfigFolder, "mainObject.prefab");
            string dynamicAssetPath = Path.Combine(k_TestConfigFolder, "dynamicObject.mat");

            AssetDatabase.CreateAsset(mat, dynamicAssetPath);
            PrefabUtility.SaveAsPrefabAsset(mainObject, mainAssetPath);
            AssetDatabase.SaveAssets();

            var mainEntry = Settings.CreateOrMoveEntry(AssetDatabase.AssetPathToGUID(mainAssetPath), mainAssetGroup);

            Settings.CreateOrMoveEntry(AssetDatabase.AssetPathToGUID(dynamicAssetPath), dynamicContentGroup);

            List <AddressableAssetEntry> modifiedEntries = new List <AddressableAssetEntry>()
            {
                mainEntry
            };

            Dictionary <AddressableAssetEntry, List <AddressableAssetEntry> > staticDependencies = new Dictionary <AddressableAssetEntry, List <AddressableAssetEntry> >()
            {
                { mainEntry, new List <AddressableAssetEntry>() }
            };

            ContentUpdateScript.GetStaticContentDependenciesForEntries(Settings, ref staticDependencies);

            Assert.AreEqual(1, staticDependencies.Count);
            Assert.AreEqual(0, staticDependencies[mainEntry].Count);

            //Cleanup
            GameObject.DestroyImmediate(mainObject);

            Settings.RemoveGroup(mainAssetGroup);
            Settings.RemoveGroup(dynamicContentGroup);

            AssetDatabase.DeleteAsset(mainAssetPath);
            AssetDatabase.DeleteAsset(dynamicAssetPath);
        }
Пример #23
0
    public static void CheckForContentUpdate()
    {
        BuildLuaAndProto();
        var buildPath = ContentUpdateScript.GetContentStateDataPath(false);
        var settings  = AddressableAssetSettingsDefaultObject.Settings;
        var entrys    = ContentUpdateScript.GatherModifiedEntries(settings, buildPath);

        if (entrys.Count == 0)
        {
            return;
        }
        var groupName = string.Format("UpdateGroup_{0}", System.DateTime.Now.ToString("yyyyMMdd"));

        ContentUpdateScript.CreateContentUpdateGroup(settings, entrys, groupName);
    }
        void OnPrepareUpdate()
        {
            var path = ContentUpdateScript.GetContentStateDataPath(true);

            if (string.IsNullOrEmpty(path))
            {
                Debug.LogWarning("No path specified for Content State Data file.");
            }
            else if (!File.Exists(path))
            {
                Debug.LogWarningFormat("No Content State Data file exists at path: {0}");
            }
            else
            {
                ContentUpdatePreviewWindow.PrepareForContentUpdate(AddressableAssetSettingsDefaultObject.Settings, path);
            }
        }
Пример #25
0
        public void OnGUI()
        {
            if (m_Entries == null)
            {
                return;
            }
            Rect contentRect = new Rect(0, 0, position.width, position.height - 50);

            if (m_Tree == null)
            {
                if (m_TreeState == null)
                {
                    m_TreeState = new TreeViewState();
                }

                var headerState = ContentUpdateTreeView.CreateDefaultMultiColumnHeaderState();
                if (MultiColumnHeaderState.CanOverwriteSerializedFields(m_Mchs, headerState))
                {
                    MultiColumnHeaderState.OverwriteSerializedFields(m_Mchs, headerState);
                }
                m_Mchs = headerState;

                m_Tree = new ContentUpdateTreeView(this, m_TreeState, m_Mchs);
                m_Tree.Reload();
            }

            m_Tree.OnGUI(contentRect);
            GUILayout.BeginArea(new Rect(0, position.height - 50, position.width, 50));
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Cancel"))
            {
                Close();
            }
            using (new EditorGUI.DisabledScope(m_Tree.GetEnabledEntries().Count == 0))
            {
                if (GUILayout.Button("Apply Changes"))
                {
                    ContentUpdateScript.CreateContentUpdateGroup(m_Settings, m_Tree.GetEnabledEntries(), "Content Update");
                    Close();
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.EndArea();
        }
Пример #26
0
        private static void UpdateAddressablesBuild()
        {
            ExitCode code = ExitCode.UnknownError;

            BuildScript.buildCompleted += result =>
            {
                if (!string.IsNullOrEmpty(result.Error))
                {
                    code = ExitCode.AddressablesBuildFailed;
                }
                else
                {
                    code = ExitCode.Success;
                }
            };

            // find out what version we are updating

            string statePath = "Artifacts/addressables_content_state.bin";
            var    state     = ContentUpdateScript.LoadContentState(statePath);

            if (state != null)
            {
                Debug.Log("State file found, " + state.playerVersion);
            }
            code = state == null ? ExitCode.AddressablesContentFileNotFound : ExitCode.Success;

            List <AddressableAssetEntry> entries = ContentUpdateScript.GatherModifiedEntries(AddressableAssetSettingsDefaultObject.Settings, statePath);

            foreach (AddressableAssetEntry assetEntry in entries)
            {
                Debug.Log("Entry found to be moved - " + assetEntry.address);
            }
            Debug.Log("Creating update group");
            ContentUpdateScript.CreateContentUpdateGroup(AddressableAssetSettingsDefaultObject.Settings, entries, "Update Group");
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);
            ContentUpdateScript.BuildContentUpdate(AddressableAssetSettingsDefaultObject.Settings, statePath);

            // TODO edit catalog name.

            ExitOnError(code);
        }
    public static void ShellBuild(string profile = "Default")
    {
        SetDataBuilder();
        var aaSettings = AddressableAssetSettingsDefaultObject.Settings;

        if (aaSettings != null && aaSettings.BuildRemoteCatalog)
        {
            var id = aaSettings.profileSettings.GetProfileId(profile);
            aaSettings.activeProfileId = id;
            string path = ContentUpdateScript.GetContentStateDataPath(false);
            if (File.Exists(path))
            {
                ContentUpdateScript.BuildContentUpdate(AddressableAssetSettingsDefaultObject.Settings, path);
            }
            else
            {
                AddressableAssetSettings.BuildPlayerContent();
            }
        }
    }
        public void GatherModifiedEntriesOnDupeGroup_DoesNotThrow()
        {
            //Setup
            var group1 = Settings.CreateGroup("CheckDupeDepencency1", false, false, false, null, typeof(BundledAssetGroupSchema));
            var group2 = Settings.CreateGroup("CheckDupeDepencency2", false, false, false, null, typeof(BundledAssetGroupSchema));

            Settings.CreateOrMoveEntry(AssetDatabase.AssetPathToGUID(k_CheckDupePrefabA), group1, false, false);
            Settings.CreateOrMoveEntry(AssetDatabase.AssetPathToGUID(k_CheckDupePrefabB), group2, false, false);

            var rule = new CheckBundleDupeDependencies();

            //Test
            rule.FixIssues(Settings);

            var path = "Assets/addressables_content_state.bin";

            Assert.DoesNotThrow(() =>
            {
                ContentUpdateScript.GatherModifiedEntries(Settings, path);
            });
        }
Пример #29
0
        public void PrepareContentUpdate()
        {
            var group  = Settings.CreateGroup("LocalStuff2", false, false, false, null);
            var schema = group.AddSchema <BundledAssetGroupSchema>();

            schema.BuildPath.SetVariableByName(Settings, AddressableAssetSettings.kLocalBuildPath);
            schema.LoadPath.SetVariableByName(Settings, AddressableAssetSettings.kLocalLoadPath);
            schema.BundleMode = BundledAssetGroupSchema.BundlePackingMode.PackTogether;
            group.AddSchema <ContentUpdateGroupSchema>().StaticContent = true;

            var entry = Settings.CreateOrMoveEntry(m_AssetGUID, group);

            entry.address = "test";

            var context = new AddressablesDataBuilderInput(Settings);

            Settings.ActivePlayerDataBuilder.BuildData <AddressablesPlayerBuildResult>(context);

            var path = AssetDatabase.GUIDToAssetPath(m_AssetGUID);
            var obj  = AssetDatabase.LoadAssetAtPath <GameObject>(path);

            obj.GetComponent <Transform>().SetPositionAndRotation(new Vector3(10, 10, 10), Quaternion.identity);
#if UNITY_2018_3_OR_NEWER
            PrefabUtility.SavePrefabAsset(obj);
#else
            EditorUtility.SetDirty(obj);
#endif
            AssetDatabase.SaveAssets();
            var tempPath        = Path.GetDirectoryName(Application.dataPath) + "/Library/com.unity.addressables/StreamingAssetsCopy/" + PlatformMappingService.GetPlatform() + "/addressables_content_state.bin";
            var modifiedEntries = ContentUpdateScript.GatherModifiedEntries(Settings, tempPath);
            Assert.IsNotNull(modifiedEntries);
            Assert.GreaterOrEqual(modifiedEntries.Count, 1);
            ContentUpdateScript.CreateContentUpdateGroup(Settings, modifiedEntries, "Content Update");
            var contentGroup = Settings.FindGroup("Content Update");
            Assert.IsNotNull(contentGroup);
            var movedEntry = contentGroup.GetAssetEntry(m_AssetGUID);
            Assert.AreSame(movedEntry, entry);
            Settings.RemoveGroup(group);
        }
Пример #30
0
    public override async Task <bool> Process(PipeContext context)
    {
        if (context == null)
        {
            throw new ArgumentNullException("context");
        }

        if (context.setting == null)
        {
            throw new System.ArgumentNullException("context.setting");
        }

        string stateAssetPath = context.setting.ConfigFolder;

        stateAssetPath = Path.Combine(stateAssetPath, PlatformMappingService.GetPlatform().ToString());
        var  content_state_path = Path.Combine(stateAssetPath, "addressables_content_state.bin");
        var  result             = ContentUpdateScript.BuildContentUpdate(context.setting, content_state_path);
        bool buildSuccess       = result != null && string.IsNullOrEmpty(result.Error);

        await Task.FromResult(true);

        return(buildSuccess);
    }