protected override void OnCreate() { this._graph = this.World.GetOrCreateSystem <AudioSystem>() .Graph; using (var block = this._graph.CreateCommandBlock()) { this._current = this.CreateNode(block); this._previous = this.CreateNode(block); } }
public void ChangeMusicTrack(AudioSampleSet sample) { var random = sample.RandomSample(); if (!random.HasValue) { return; } // swap the current and previous var current = this._previous; this._previous = this._current; this._current = current; using (var block = this._graph.CreateCommandBlock()) { block.TriggerAudioSample( this._current.node, random.Value.ToReader(true), Categories.Music ); block.SetAttenuation( this._current.connection, 1f, AudioSettings.outputSampleRate * 15 ); block.SetAttenuation( this._previous.connection, 0f, AudioSettings.outputSampleRate * 4 ); } }
private void RemoveState(Entity entity, ref AudioClipPlayerSystemState state) { this.PostUpdateCommands.RemoveComponent <AudioClipPlayerSystemState>(entity); this._graph.TerminateAudioSampleNode(state.node); }
private void UpdateState(Entity entity, ref AudioClipPlayerSystemState state) { }