Search Unity

Script creates an error

Discussion in 'Scripting' started by MKPDK, Sep 10, 2019.

  1. MKPDK

    MKPDK

    Joined:
    Sep 10, 2019
    Posts:
    1
    I made a script to change volume but i get error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement

    Can you help me fix it?

    This is the script:


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Audio;
    5.  
    6. public class SettingsMenu : MonoBehaviour
    7. {
    8.     public AudioMixer audioMixer;
    9.  
    10.     public void SetVolume(float volume)
    11.     {
    12.         audioMixer.SetFloat; ("volume", volume);
    13.     }
    14. }
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,752
    Spelling and punctuation are critical in programming. It appears you hand-typed this code in, and at a minimum there is an extra semicolon between the SetFloat function name and the open parenthesis.