コード例 #1
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");
        }
コード例 #2
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);
    }
コード例 #3
0
        internal 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);
        }
コード例 #4
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);
    }
コード例 #5
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 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);
            });
        }
コード例 #7
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);
        }