How To Make A Volume Slider In 4 Minutes - Easy Unity Tutorial

How To Make A Volume Slider In 4 Minutes - Easy Unity Tutorial

Hooson

3 года назад

69,563 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Asif
Asif - 25.10.2023 13:04

Great

Ответить
xCADE
xCADE - 16.09.2023 22:13

Hi the buttons weren't showing up is there a reason to it why isnt it showing when i hit play?

Ответить
SheReacts
SheReacts - 05.08.2023 22:34

Bro I don't understand

Ответить
Cuty Dina
Cuty Dina - 27.02.2023 02:25

Very useful, thanks!

Ответить
Pixlux
Pixlux - 08.02.2023 02:42

Thanks

Ответить
oterobot
oterobot - 04.02.2023 17:27

Thank you

Ответить
Talisman Skulls
Talisman Skulls - 29.01.2023 11:26

I like the concept but i am using sliders to adjust audio source. how do i mute those/

Ответить
Dani Ionaș
Dani Ionaș - 18.01.2023 00:15

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);

}

}

Ответить
Phellippe Motta
Phellippe Motta - 15.12.2022 15:47

WOW, easy, simple and PERFECT. Thank you!

Ответить
Shivaprasad k m
Shivaprasad k m - 07.10.2022 07:22

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.

Ответить
Miguel Espeso
Miguel Espeso - 03.10.2022 01:37

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.

Ответить
Luck
Luck - 16.08.2022 17:02

Thank you so much!!!!!

Ответить
crispy chips
crispy chips - 12.08.2022 04:35

Thank you for making these videos they're a really big help

Ответить
Kanon Modz
Kanon Modz - 16.06.2022 15:51

this didnt help whats so ever thanks for wasting my time

Ответить
Lucas Oliveira
Lucas Oliveira - 11.06.2022 09:19

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?

Ответить
UpcomingChris
UpcomingChris - 29.05.2022 19:55

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?

Ответить
Rémy Beaumont
Rémy Beaumont - 15.05.2022 20:10

Merci mec, tu m'as permis d'avoir 10%

Ответить
Wee Jun Jie
Wee Jun Jie - 11.05.2022 04:02

I know this a long time vid, but just to ask why at the unity On Click Part, I cant add Function to it

Ответить
Mako Fujihara
Mako Fujihara - 21.03.2022 12:59

By the gods, you are a life saver T^T <3

Ответить
F.Fifie.
F.Fifie. - 18.03.2022 18:30

why mine didnt have music if i change to different scene? please helppp

Ответить