示例#1
0
        private void OnBasePackingModeChanged(PackingMode newValue)
        {
            var oldValue = _settingsService.GetState().BasePackingMode.Value;

            _history.Register($"Update {nameof(_window.BasePackingMode)}",
                              () =>
            {
                _settingsService.UpdateSetting(newValue);
                _settingsService.Save();
                if (DisplayReprocessConfirmationDialog(nameof(ReadOnlySetting.BasePackingMode)))
                {
                    _assetProcessService.ReprocessAllAssetsInAddressablesFolder(false);
                }
                else
                {
                    _settingsService.UpdateSetting(oldValue);
                    _settingsService.Save();
                }
            },
                              () =>
            {
                _settingsService.UpdateSetting(oldValue);
                _settingsService.Save();
                if (DisplayReprocessConfirmationDialog(nameof(ReadOnlySetting.BasePackingMode)))
                {
                    _assetProcessService.ReprocessAllAssetsInAddressablesFolder(false);
                }
                else
                {
                    _settingsService.UpdateSetting(newValue);
                    _settingsService.Save();
                }
            });
        }
示例#2
0
        /// <summary>
        ///     Generate a group name from a asset path.
        /// </summary>
        /// <param name="assetPath"></param>
        /// <param name="packingMode"></param>
        /// <returns></returns>
        /// <exception cref="InvalidOperationException"></exception>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        public string GenerateFromAssetPath(string assetPath, PackingMode packingMode)
        {
            switch (packingMode)
            {
            case PackingMode.PackByAddressablesFolder:
                var addressableFolderRegex =
                    new Regex($"(?<folder_path>^Assets.*/{Paths.GetAddressablesFolderName()})/");
                var match = addressableFolderRegex.Match(assetPath);
                if (!match.Success)
                {
                    return(string.Empty);
                }

                var addressableFolderPath = match.Groups["folder_path"].Value;
                var guid = _assetDatabaseAdapter.AssetPathToGUID(addressableFolderPath);
                if (string.IsNullOrEmpty(guid))
                {
                    return(string.Empty);
                }

                guid = guid.Substring(0, 7);

                return($"{Paths.GetDefaultGroupName()}_{guid}");

            case PackingMode.PackTogether:
                return(Paths.GetDefaultGroupName());

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#3
0
        public void SetPackingMode_CanSet()
        {
            const PackingMode packingMode = PackingMode.PackByAddressablesFolder;
            var setting = new Setting();

            setting.SetBasePackingMode(packingMode);

            Assert.That(setting.BasePackingMode.Value, Is.EqualTo(packingMode));
        }
示例#4
0
 public void SetBasePackingMode(PackingMode packingMode)
 {
     _basePackingMode.Value = packingMode;
 }
        /// <summary>
        ///     Build <see cref="EntryCreateOrMoveOperationInfo" />.
        /// </summary>
        /// <param name="assetPath"></param>
        /// <param name="defaultAddressingMode"></param>
        /// <param name="defaultPackingMode"></param>
        /// <param name="defaultGroupTemplateGuid"></param>
        /// <param name="rules"></param>
        /// <returns></returns>
        public EntryCreateOrMoveOperationInfo BuildEntryCreateOrMoveInfo(string assetPath,
                                                                         AddressingMode defaultAddressingMode, PackingMode defaultPackingMode, string defaultGroupTemplateGuid,
                                                                         EntryRuleSet rules)
        {
            Assert.IsFalse(string.IsNullOrEmpty(assetPath));
            Assert.IsFalse(string.IsNullOrEmpty(_assetDatabaseAdapter.GUIDToAssetPath(defaultGroupTemplateGuid)));

            // Do not process the folder.
            if (Directory.Exists(assetPath))
            {
                return(null);
            }

            var addressablePath = _addressablePathGenerateService.GenerateFromAssetPath(assetPath);

            if (string.IsNullOrEmpty(addressablePath))
            {
                return(null);
            }

            // Determine all rules.
            if (rules != null)
            {
                var info = BuildEntryCreateOrMoveInfoByRules(assetPath, rules, defaultGroupTemplateGuid);
                if (info != null)
                {
                    return(info);
                }
            }

            // Apply the default settings if none of the rules are matched.
            var address =
                _addressGenerateDomainService.GenerateFromAddressablePath(addressablePath, defaultAddressingMode);
            var groupName         = _groupNameGenerateService.GenerateFromAssetPath(assetPath, defaultPackingMode);
            var groupTemplateGuid = defaultGroupTemplateGuid;

            return(new EntryCreateOrMoveOperationInfo(assetPath, address, groupName, groupTemplateGuid, null));
        }