-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAudioExample.cs
More file actions
39 lines (36 loc) · 1.2 KB
/
AudioExample.cs
File metadata and controls
39 lines (36 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
namespace Pollus.Examples;
using Pollus.Engine;
using Pollus.ECS;
using Pollus.Engine.Audio;
using Pollus.Assets;
public class AudioExample : IExample
{
public string Name => "audio";
IApplication? application;
public void Stop() => application?.Shutdown();
public void Run()
{
application = Application.Builder
.AddPlugin(new AssetPlugin { RootPath = "assets" })
.AddPlugin<TimePlugin>()
.AddPlugin<AudioPlugin>()
.AddSystems(CoreStage.PostInit, FnSystem.Create("Setup",
static (World world, AssetServer assetServer) =>
{
Entity.With(
new AudioSource
{
Gain = 1.0f,
Pitch = 1.0f,
Mode = PlaybackMode.Loop,
},
new AudioPlayback
{
Asset = assetServer.LoadAsync<AudioAsset>("sounds/test.wav"),
}
).Spawn(world);
}))
.Build();
application.Run();
}
}