Usage.Unity Projects - JuDelCo/Core GitHub Wiki
Install (Unity projects)
Add the following git URL in the package manager of your project:
https://github.com/JuDelCo/Core.git#v1.49.0
If you keep the version in the URL, Unity will download always that version even if there are new versions of this repository so you can work in a stable environment.
Alternatively, you can add this dependency by modifying the /Packages/manifest.json
file in your project folder.
Please note that the minimum version supported is Unity 2019.3 or later (it won't work in older versions).
Quickstart configuration
To use services you need to register them first. One way you can automatically register the services on runtime is creating this static class anywhere in your project, it will run before any scene so it's the perfect entry point for the services to setup:
using UnityEngine;
using Ju.Services;
public static class Bootstrap
{
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
private static void Init()
{
// Core services
ServiceContainer.RegisterService<ITaskService, TaskService>();
ServiceContainer.RegisterService<ICoroutineService, CoroutineService>();
ServiceContainer.RegisterService<ICacheService, CacheService>();
// Unity related services
ServiceContainer.RegisterService<ILogUnityService, LogUnityService>();
ServiceContainer.RegisterService<IInputService, InputUnityService>();
ServiceContainer.RegisterService<ITimeService, UnityTimeService>();
ServiceContainer.RegisterService<IUnityService, UnityService>();
ServiceContainer.RegisterService<IPrefabPoolService, PrefabPoolService>();
// Register your custom services here
}
}
You can rename the class and the method to whatever you want.
Alternative (register services manually)
You can register the services in your own entry point method to control whenever the services get registered like it's done in native C# projects. Just keep in mind that the UnityService
will fire all the update loop events and dispose the Service Container automatically.
Next steps
Read how to use the Service Container and how to create your own Services.
After that, read about the Update Loop Events you can use, how to do logging and what LinkHandlers are.