Skip to content

Content Loading

TinyPlay edited this page Aug 5, 2022 · 1 revision

Content Providers

The Content Providers may be used to load some content from disk. For example - basic content providers in the XDot Framework used to load Game Views from Resources or Addressables.

Note! For Content Providers in the XDot Framework used UniTask Library. You can rewrite it without UniTask, but this library is very useful for async content loading

Addressables Provider

The first provider out-of-the box. If your project is not using addressables, this feature was been disabled.

Usage Example:

AddressablesLoader<GameObject> contentLoader = new AddressablesLoader<GameObject>();
contentLoader?.Load("PathToAddressableAsset", onComplete, onError);

Resources Provider

The second provider out-of-the box used to load objects from Resources Folder. Please, note - use Resource loading for any objects - is a bad idea (for performance reasons). Please, use addressables or your content loading system instead.

Usage Example:

ResourcesLoader<GameObject> contentLoader = new ResourcesLoader<GameObject>();
contentLoader?.Load("PathToAddressableAsset", onComplete, onError);

Your Own Providers

You can write your own content loading system. Any Content Providers has a single interface.

XDot Framework Content Provider Interface:

using System;
using Cysharp.Threading.Tasks;
using XDot.Handlers;

namespace XDot.ContentLoader
{
    public interface IContentLoader<TContent> where TContent : class
    {
        UniTask<TContent> Load(string path, Action<TContent> onComplete = null,
            Action<ErrorHandler> onError = null);

        void Cancel();
        void Dispose();
    }
}

General Topics:

Development Info

This framework is under MIT license. Developed by Ilya Rastorguev specially for Pixel Incubator.

Contacts

You can ask me about XDot Framework using Telegram @SodaBoom or by email: iliya-sdt@yandex.ru

Clone this wiki locally