- Home /
cannot implicitly convert type 'int' to 'bool' problem
I am getting this error. This is my script. using UnityEngine; using System.Collections;
public class volumechange : MonoBehaviour { public static int volume;
// Update is called once per frame
void Update () {
if (volume = 1)
AudioSource.volume = 10;
if (volume = 0)
AudioSource.volume = 0;
}
}
Comment
Best Answer
Answer by TonyLi · Dec 20, 2013 at 02:32 PM
Use "==" to compare equality. The single "=" is assignment.
Also, click the "101/010" button when entering code on unityAnswers to get it formatted correctly.
using UnityEngine;
using System.Collections;
public class volumechange : MonoBehaviour {
public static int volume;
// Update is called once per frame
void Update () {
if (volume == 1)
AudioSource.volume = 10;
if (volume == 0)
AudioSource.volume = 0;
}
}
Your answer
Follow this Question
Related Questions
an object reference is required to access non static member problem 0 Answers
Trying to make a volume slider bar, Part 2 0 Answers
Static int wont change from another script 0 Answers
Static Integers Problem 1 Answer
How to avoid audio glitches whilst switching volume of an Audiosource each Update()-Frame? 0 Answers