-
Notifications
You must be signed in to change notification settings - Fork 1
Usage.Native CSharp Projects
Run the following command in the console of your .NET project to add the package:
dotnet add package JuDelCo.Lib.Core
In native C# applications, you need to ensure the lifecycle of the Service Container and fire some events.
First, at some point in the entry point of the logic of your program, register the services using:
ServiceContainer.RegisterService<ITaskService, TaskService>();
ServiceContainer.RegisterService<ICoroutineService, CoroutineService>();
ServiceContainer.RegisterService<ICacheService, CacheService>();
// Note: You need to implement your custom C# native providers for these services if you need to use them
// ServiceContainer.RegisterService<ILogService, LogConsoleService>();
// ServiceContainer.RegisterService<IInputService, InputNativeService>();
// ServiceContainer.RegisterService<ITimeService, TimeNativeService>();
// Register your custom services
Note: The IEventBusService
is core and therefore is registered automatically, you can't unload this service.
During the update loop of your application you need to fire events so some Services that depends on them (like the Coroutine and Task services) work as intended:
// Update loop
ServiceContainer.Get<IEventBusService>().Fire(new TimePreUpdateEvent(deltaTime));
ServiceContainer.Get<IEventBusService>().Fire(new TimeUpdateEvent(deltaTime));
ServiceContainer.Get<IEventBusService>().Fire(new TimePostUpdateEvent(deltaTime));
// Fixed update loop
ServiceContainer.Get<IEventBusService>().Fire(new TimePreFixedUpdateEvent(fixedDeltaTime));
ServiceContainer.Get<IEventBusService>().Fire(new TimeFixedUpdateEvent(fixedDeltaTime));
ServiceContainer.Get<IEventBusService>().Fire(new TimePostFixedUpdateEvent(fixedDeltaTime));
// others ... (physics events)
Before the program finalizes, you should dispose all the services using:
ServiceContainer.Dispose();
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.
Return to [Home]
- Home
- Install
- Manual
-
Core API
- Services:
- Util:
-
Unity API
- Services:
- Integrations: