using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AudSys : MonoBehaviour
{
public Text volumeAmount;
public void SetAudio(float value)
{
AudioListener.volume = value;
volumeAmount.text = ((int)value * 100).ToString();
}
}
So… what’s the problem? You should be able to see the volumeAmount Text in the inspector.
Does the object you attempt to drag there have a Text component?
AudioListener Is defined. Your script has errors and won’t compile so it’s not working.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AudSys : MonoBehaviour
{
public Text volumeAmount;
// Reference to the AudioListener component assigned in the Inspector
public AudioListener audioListener;
public void SetAudio(float value)
{
if (audioListener != null)
{
audioListener.volume = value;
volumeAmount.text = ((int)(value * 100)).ToString();
}
else
{
Debug.LogWarning("AudioListener is not assigned.");
}
}
}