Update the cards to pull in from addressables to wokr in build, remove erronous code preventing building
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using AppleHills.Core.Settings;
|
||||
using Core;
|
||||
@@ -72,10 +73,37 @@ namespace Utils
|
||||
return frameAdjustedSpeed * screenNormalizationFactor;
|
||||
}
|
||||
|
||||
public static bool AddressableKeyExists(object key)
|
||||
public static bool AddressableKeyExists(object key, Addressables.MergeMode mergeMode = Addressables.MergeMode.Union)
|
||||
{
|
||||
IList<IResourceLocation> locations;
|
||||
return Addressables.LoadResourceLocationsAsync(key).WaitForCompletion()?.Count > 0;
|
||||
try
|
||||
{
|
||||
// Handle different key types
|
||||
if (key is string[] keyArray)
|
||||
{
|
||||
// For string arrays, use the array as is with merge mode
|
||||
return Addressables.LoadResourceLocationsAsync(keyArray, mergeMode).WaitForCompletion()?.Count > 0;
|
||||
}
|
||||
else if (key is IEnumerable<object> keyList)
|
||||
{
|
||||
// For collections of keys, convert to object[]
|
||||
return Addressables.LoadResourceLocationsAsync(keyList.ToArray(), mergeMode).WaitForCompletion()?.Count > 0;
|
||||
}
|
||||
else if (key is string stringKey)
|
||||
{
|
||||
// For single string keys, wrap in array
|
||||
return Addressables.LoadResourceLocationsAsync(new string[] { stringKey }, mergeMode).WaitForCompletion()?.Count > 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// For other single keys (AssetReference, etc.), wrap in object[]
|
||||
return Addressables.LoadResourceLocationsAsync(new object[] { key }, mergeMode).WaitForCompletion()?.Count > 0;
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"[AppleHillsUtils] Error checking addressable key existence: {ex.Message}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user