Update the cards to pull in from addressables to wokr in build, remove erronous code preventing building

This commit is contained in:
Michal Adam Pikulski
2025-10-21 10:05:49 +02:00
parent d1792014db
commit af77e07f99
20 changed files with 531 additions and 84 deletions

View File

@@ -1,10 +1,9 @@
using System.IO;
using System.Linq;
using AppleHills.Editor.Utilities;
using Bootstrap;
using UnityEditor;
using UnityEditor.AddressableAssets;
using UnityEditor.AddressableAssets.Settings;
using UnityEditor.AddressableAssets.Settings.GroupSchemas;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.AddressableAssets;
@@ -160,10 +159,15 @@ namespace Editor.Bootstrap
private static AddressableAssetEntry CreateCustomBootSettingsEntry(CustomBootSettings bootSettings,
AddressableAssetGroup group, string key)
{
var settings = AddressableAssetSettingsDefaultObject.Settings;
var entry = settings.CreateOrMoveEntry(
AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(bootSettings)),
group);
string assetPath = AssetDatabase.GetAssetPath(bootSettings);
var settings = AddressablesUtility.GetAddressableSettings(false);
if (settings == null || string.IsNullOrEmpty(assetPath) || group == null)
{
return null;
}
var guid = AssetDatabase.AssetPathToGUID(assetPath);
var entry = settings.CreateOrMoveEntry(guid, group);
entry.address = key;
settings.SetDirty(AddressableAssetSettings.ModificationEvent.EntryMoved, entry, true);
return entry;
@@ -189,21 +193,7 @@ namespace Editor.Bootstrap
/// <returns></returns>
private static AddressableAssetGroup GetOrCreateGroup(string name, bool includeInBuild)
{
// Use GetSettings(true) to ensure the settings asset is created if missing
var settings = AddressableAssetSettingsDefaultObject.GetSettings(true);
if (settings == null)
{
Debug.LogError("AddressableAssetSettings could not be found or created. Please ensure Addressables are set up in your project.");
return null;
}
var group = settings.FindGroup(name);
if (group == null)
{
group = settings.CreateGroup(name, false, false, true, settings.DefaultGroup.Schemas);
group.GetSchema<BundledAssetGroupSchema>().IncludeInBuild = includeInBuild;
}
return group;
return AddressablesUtility.GetOrCreateGroup(name, includeInBuild);
}
/// <summary>