Skip to content

Services

Valk edited this page Sep 27, 2024 · 25 revisions

Using the static keyword in GameServer.cs for all attributes may initially seem convenient for accessing game server properties across different parts of the code. However, this approach poses significant challenges. When the server restarts or transitions between scenes, static properties retain their values, causing inconsistencies.

Manually resetting each static property to address these issues is cumbersome and error-prone. This demonstrates the need for careful consideration when using static properties, as they can simplify initial development but complicate maintenance and scalability.

[Service(ServiceLifeTime.Scene)] // or use ServiceLifeTime.Application
public partial class UIVignette : ColorRect
{
    public void LightPulse() { ... }
}
UIVignette vignette = Services.Get<UIVignette>();
vignette.LightPulse();
Clone this wiki locally