private T LoadAssetAtGuid <T>(string guid) where T : Object { var templateAssetPath = _assetDatabaseAdapter.GUIDToAssetPath(guid); if (string.IsNullOrEmpty(templateAssetPath)) { throw new Exception($"{typeof(T).Name} (GUID:{guid}) is not found."); } return(LoadAssetAtPath <T>(templateAssetPath)); }
/// <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)); }
private void SetDefaultGroupTemplateIfNeeded() { if (string.IsNullOrEmpty(_setting.GroupTemplateGuid.Value) || string.IsNullOrEmpty(_assetDatabaseAdapter.GUIDToAssetPath(_setting.GroupTemplateGuid.Value))) { if (_addressableSettings.GroupTemplateObjects.Count == 0) { throw new InvalidOperationException( $"There is no valid {nameof(AddressableAssetGroupTemplate)} in {nameof(AddressableAssetSettings)}."); } var templateAsset = _addressableSettings.GroupTemplateObjects[0]; var templateAssetPath = _assetDatabaseAdapter.GetAssetPath(templateAsset); var templateAssetGuid = _assetDatabaseAdapter.AssetPathToGUID(templateAssetPath); _setting.SetGroupTemplateGuid(templateAssetGuid); } }