这是第一个 Unity 开放项目的repo,是 Unity 和社区合作创建的一个小型开源游戏演示,第一款游戏是一款名为 Chop Chop 的动作冒险游戏。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

44 行
1.2 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SettingsSystemAudioComponent : SettingsSystemSubComponents
{
[SerializeField] Slider musicVolumeSlider;
[SerializeField] Slider sfxVolumeSlider;
public float MusicVolume { get; private set; }
public float SfxVolume { get; private set; }
void Start()
{
Setup();
}
protected override void Setup()
{
//TODO: load previous music volume setting
MusicVolume = 50f;
musicVolumeSlider.SetValueWithoutNotify(MusicVolume);
//TODO: load previous sfx volume setting
SfxVolume = 50f;
sfxVolumeSlider.SetValueWithoutNotify(SfxVolume);
}
#region UI CALLBACKS
//TODO: clamp volume to [0, 1] or [0, 100]? Change Slider min max value in editor depending on use case
public void OnChangeMusicVolume(float volume)
{
MusicVolume = Mathf.Clamp(volume, 0.0f, 100.0f);
}
//TODO: clamp volume to [0, 1] or [0, 100]? Change Slider min max value in editor depending on use case
public void OnChangeSfxVolume(float volume)
{
SfxVolume = Mathf.Clamp(volume, 0.0f, 100.0f);
}
#endregion
}