UnityAPI手册-2019.4官网版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
AudioSource.volume
# [AudioSource](https://docs.unity3d.com/cn/2019.4/ScriptReference/AudioSource.html).volume public float **volume** ; ## 描述 音频源的音量(0.0 到 1.0)。 AudioSource 的音量属性控制来自 AudioClip 的声音级别。最高音量等级为 1,最低音量为 0(此时听不到声音)。 ``` using UnityEngine; public class Example : MonoBehaviour { AudioSource m_MyAudioSource; //Value from the slider, and it converts to volume level float m_MySliderValue; void Start() { //Initiate the Slider value to half way m_MySliderValue = 0.5f; //Fetch the AudioSource from the GameObject m_MyAudioSource = GetComponent<AudioSource>(); //Play the AudioClip attached to the AudioSource on startup m_MyAudioSource.Play(); } void OnGUI() { //Create a horizontal Slider that controls volume levels. Its highest value is 1 and lowest is 0 m_MySliderValue = GUI.HorizontalSlider(new Rect(25, 25, 200, 60), m_MySliderValue, 0.0F, 1.0F); //Makes the volume of the Audio match the Slider value m_MyAudioSource.volume = m_MySliderValue; } } ```
da
2022年5月24日 10:03
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码