/LLM-Containers

[Unity] [Tool] Uni-Task lightweight containers for loadable pages/textures/scenes/prefabs/resources

Primary LanguageC#

Unity Uni-Task lightweight content/data-related containers

Yes, IT IS better and faster than Unity coroutines

Ok but how to actually use it?

Required UniTask itself, so first-thing-first install a .unitypackage from this link. Can be used for default .NET classes if you install UniTask as NuGet package. Also feel free to change whatever you want or collab.

Simple example where we have our popups inside Popups folder (Assets/Resources/Popups/), and we need to get our prefab which is MonoContainer inherited and called Friend Invite Popup:

Popup Prefab screenshot

First create a factory, our base one or your custom one (you can inherit and override creation process for your needs):

_popupsFactory = new BaseResourceFactory("Popups", _popupScreenRoot.transform);

Lets get the Friend Invite Popup from Resources/Popups/ and pass it whoever, since MonoContainer.Data inside is initialized and Unity GameObject already created:

var container = await _popupsFactory
.CreateInstance<FriendInvitePopup, InviteData>(new InviteData(_friend, _unixTimeRequestCreated));

Remark: You can create new factories and override creation methods and you can pass any data to a container, just create class and inherit ContainerData (for example public class LoginData : ContainerData), or even pass a null or new ContainerData() if u dont need it for some reason