Register System
MrScautHD edited this page Oct 28, 2023
·
3 revisions
The Register system empowers you to efficiently manage your resources. To get started, you'll create a new class that extends the Registry
class. Then, utilize the Register
method to register your objects.
public class ShaderRegistry : Registry {
public static Shader LightShader { get; private set; }
/// <summary>
/// Used for Initializes objects.
/// </summary>
protected internal override void Init() {
base.Init();
}
/// <summary>
/// Used for loading resources.
/// </summary>
protected internal override void Load() {
base.Load();
LightShader = this.Register("light", () => this.Content.Load<Shader>("shaders/lighting"));
}
}
To incorporate the type, it's essential to override the OnRun
method within your Game class.
public class MyGame : Game {
public MyGame(GameSettings settings) : base(settings) {}
protected override void OnRun() {
base.OnRun();
RegistryManager.AddType(new ShaderRegistry());
}
}
Sparkle Engine - Visit the official Sparkle GitHub repository for the latest updates and source code.
Copyright © [Stellution Studios] | Licensed under the MIT License