Audio volume setting (#394)

Volume setting for audio volumes
This commit is contained in:
TerrificTrifid 2022-09-17 10:15:29 -05:00 committed by GitHub
commit b5a4c9f7ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 0 deletions

View File

@ -46,6 +46,7 @@ namespace NewHorizons.Builder.Volumes
var owAudioSource = go.AddComponent<OWAudioSource>();
owAudioSource._audioSource = audioSource;
owAudioSource.loop = info.loop;
owAudioSource.SetMaxVolume(info.volume);
owAudioSource.SetTrack((OWAudioMixer.TrackName)Enum.Parse(typeof(OWAudioMixer.TrackName), Enum.GetName(typeof(AudioMixerTrackName), info.track)));
AudioUtilities.SetAudioClip(owAudioSource, info.audio, mod);

View File

@ -4,6 +4,7 @@ using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
@ -134,6 +135,13 @@ namespace NewHorizons.External.Modules
/// Whether to loop this audio while in this audio volume or just play it once
/// </summary>
[DefaultValue(true)] public bool loop = true;
/// <summary>
/// The loudness of the audio
/// </summary>
[Range(0f, 1f)]
[DefaultValue(1f)]
public float volume = 1f;
}
[JsonObject]

View File

@ -2501,6 +2501,14 @@
"type": "boolean",
"description": "Whether to loop this audio while in this audio volume or just play it once",
"default": true
},
"volume": {
"type": "number",
"description": "The loudness of the audio",
"format": "float",
"default": 1.0,
"maximum": 1.0,
"minimum": 0.0
}
}
},