Комментарии:
Great
ОтветитьHi the buttons weren't showing up is there a reason to it why isnt it showing when i hit play?
ОтветитьBro I don't understand
ОтветитьVery useful, thanks!
ОтветитьThanks
ОтветитьThank you
ОтветитьI like the concept but i am using sliders to adjust audio source. how do i mute those/
Ответитьusing System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SoundManager : MonoBehaviour
{
[SerializeField] Image SoundONNIcon;
[SerializeField] Image SoundOFFIcon;
private bool muted = false;
void Start()
{
if (!PlayerPrefs.HasKey("muted"))
{
PlayerPrefs.SetInt("muted", 0);
Load();
}
else
{
Load();
}
UpdateButtonIcon();
AudioListener.pause = muted;
}
public void OnButtonPress()
{
if (muted == false)
{
muted = true;
AudioListener.pause = true;
}
else
{
muted = false;
AudioListener.pause = false;
}
Save();
UpdateButtonIcon();
}
private void UpdateButtonIcon()
{
if(muted == false)
{
SoundONNIcon.enabled = true;
SoundOFFIcon.enabled = true;
}
else
{
SoundONNIcon.enabled = false;
SoundOFFIcon.enabled = true;
}
}
private void Load()
{
muted = PlayerPrefs.GetInt("muted") == 1;
}
private void Save()
{
PlayerPrefs.SetInt("muted", muted ? 1 : 0);
}
}
WOW, easy, simple and PERFECT. Thank you!
ОтветитьHello i got problem that is, whenever the game starts the sound off button is enabled its not saving as set in last game,i got same issue in slider also (as u pinned in comment video).any suggestions.
ОтветитьCongratulations
It's an amazing video.
I managed to do what I was looking for to see your video.
I would be very grateful if you activated the subtitles in Spanish to fully understand your logic, I like how you explain your video, but I don't fully understand it.
Thank you so much!!!!!
ОтветитьThank you for making these videos they're a really big help
Ответитьthis didnt help whats so ever thanks for wasting my time
ОтветитьHi @Hooson,
I replicated this code to make something to turn sounds and effects on and off. The problem is that in the effects, where I set another audio, when I click the button it plays the audio sound again. I don't understand why this behavior, since they are two different scripts. Can you help me?
The PlayerPrefs part of this isn't working like I'd expect, if I close the game, change scene or something, the music will always start on regardless if I turned it off or not and I don't know why, is there something I'm missing?, code is identical, isn't it mean to be persistently saved?
ОтветитьMerci mec, tu m'as permis d'avoir 10%
ОтветитьI know this a long time vid, but just to ask why at the unity On Click Part, I cant add Function to it
ОтветитьBy the gods, you are a life saver T^T <3
Ответитьwhy mine didnt have music if i change to different scene? please helppp
Ответить