using System; using System.Collections.Generic; using UnityEngine.ResourceManagement.ResourceLocations; using UnityEngine.ResourceManagement.ResourceProviders; namespace UnityEngine.AddressableAssets.ResourceLocators { /// /// Simple locator that acts as a passthrough for assets loaded from resources directories. /// public class LegacyResourcesLocator : IResourceLocator { /// /// The key is converted to a string and used as the internal id of the location added to the locations parameter. /// /// The key of the location. This should be a string with the resources path of the asset. /// The resource type. /// The list of locations. This will have at most one item. /// True if the key is a string object and a location was created, false otherwise. public bool Locate(object key, Type type, out IList locations) { locations = null; var strKey = key as string; if (strKey == null) return false; locations = new List(); locations.Add(new ResourceLocationBase("LegacyResourceLocation", strKey, typeof(LegacyResourcesProvider).FullName, typeof(UnityEngine.Object))); return true; } #if ENABLE_BINARY_CATALOG /// /// Enumeration of all locations for this locator. This will return an empty array. /// public IEnumerable AllLocations => new IResourceLocation[0]; #endif /// /// The keys available in this locator. /// public IEnumerable Keys { get { return null; } } /// /// Id of locator. /// public string LocatorId => nameof(LegacyResourcesLocator); } }