public UniTask InitializeServiceAsync() { // Invoked when the engine is initializing, after services required in the constructor are initialized; // it's safe to use the required services here (IResourceProviderManager in this case). // Initialize item prefab loader, as per the configuration. itemLoader = Configuration.Loader.CreateLocalizableFor <GameObject>(providersManager, localizationManager); return(UniTask.CompletedTask); }
protected override LocalizableResourceLoader <Texture2D> ConstructAppearanceLoader(OrthoActorMetadata metadata) { // Override the path prefix of the loader so that background sprites // can be loaded from the root of the `/Backgrounds` folder. var providerManager = Engine.GetService <IResourceProviderManager>(); var localeManager = Engine.GetService <ILocalizationManager>(); var appearanceLoader = new LocalizableResourceLoader <Texture2D>( providerManager.GetProviders(metadata.Loader.ProviderTypes), providerManager, localeManager, metadata.Loader.PathPrefix); return(appearanceLoader); }
public async Task InitializeAsync() { foreach (var loaderConfig in cgSources) { // 1. Locate all the available textures under the source path. var loader = new LocalizableResourceLoader <Texture2D>(loaderConfig, providerManager, localizationManager); var resourcePaths = await loader.LocateAsync(string.Empty); // 2. Iterate the textures, adding them to the grid as CG slots. foreach (var resourcePath in resourcePaths) { var textureLocalPath = loader.BuildLocalPath(resourcePath); var unlockableId = $"{unlockableIdPrefix}/{textureLocalPath}"; if (grid.SlotExists(unlockableId)) { continue; } grid.AddSlot(new CGGalleryGridSlot.Constructor(grid.SlotPrototype, unlockableId, textureLocalPath, loader, HandleSlotClicked).ConstructedSlot); } } }