37 lines
682 B
Markdown
37 lines
682 B
Markdown
# SetVolume
|
|
|
|
**所属类**: `AudioSourceComponent`
|
|
|
|
**头文件**: `XCEngine/Components/AudioSourceComponent.h`
|
|
|
|
**描述**: 设置音频源的音量。
|
|
|
|
## 函数签名
|
|
|
|
```cpp
|
|
void SetVolume(float volume);
|
|
```
|
|
|
|
## 参数
|
|
|
|
| 参数 | 类型 | 描述 |
|
|
|------|------|------|
|
|
| `volume` | `float` | 音量,范围 0.0 到 1.0 |
|
|
|
|
## 使用示例
|
|
|
|
```cpp
|
|
#include <XCEngine/Components/AudioSourceComponent.h>
|
|
|
|
using namespace XCEngine::Components;
|
|
|
|
void SetAudioVolume(AudioSourceComponent* source) {
|
|
source->SetVolume(0.5f); // 50% 音量
|
|
}
|
|
```
|
|
|
|
## 相关文档
|
|
|
|
- [AudioSourceComponent](audio-source-component.md) - 音频源组件
|
|
- [GetVolume](get-volume.md) - 获取音量
|