Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
    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);
    }
Ejemplo n.º 3
0
        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);
                }
            }
        }