Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Resolved Cannot access audiosource.volume why????[SOLVED]

Discussion in 'Audio & Video' started by valeriounity, May 8, 2020.

  1. valeriounity

    valeriounity

    Joined:
    Mar 23, 2020
    Posts:
    5
    Good morning everyone,

    I have this weird issue: when I'm trying to access the volume of my audiosource variable my visual studio doesn't show me this option and (obviously) doesn't recognize it.

    What am I doing wrong?
     

    Attached Files:

  2. Hikiko66

    Hikiko66

    Joined:
    May 5, 2013
    Posts:
    1,306
    Why did you name your class "AudioSource", exactly the same name as something that already exists, and something that you are actually trying to use inside this same object?

    The reason src doesn't have a volume is because it's YOUR AudioSource class, it's not the Unity AudioSource class.

    So, src.Slider will be a thing that exists, because your AudioSource has a Slider field, but it doesn't have a volume field. you're using the wrong AudioSource.

    Name things properly.
     
    valeriounity likes this.
  3. valeriounity

    valeriounity

    Joined:
    Mar 23, 2020
    Posts:
    5
    What a dumb am I?