[SOLVED] I have an error in the PlayerPrefs

I have changed back to 4.7 since I can’t quite figure out what I need to use in 5.4 for the scenemanagement code. However I have an error that persists. this is the error - Assets/PlayerPrefsManager1.cs(11,21): error CS0019: Operator <' cannot be applied to operands of typebool’ and `float’

I have looked it over and over. I looked on Unity and in here and can’t find that anyone else had this problem. I am sure it is a simple problem I am overlooking but I keep overlooking it and could use some help.

The code it belongs to is here…
public static void UnlockLevel (int level) {
if (level <= Application.levelCount - 1) {
PlayerPrefs.SetInt (LEVEL_KEY + level.ToString (), 1);
//This acts like a boolen so 1 = true.
} else {
Debug.LogError (“Trying to unlock level not in build order”);
}

All the code is here…
using UnityEngine;
using System.Collections;

public class PlayerPrefsManager : MonoBehaviour {

const string MASTER_VOLUME_KEY = "master_volume";
const string DIFFICULTY_KEY = "difficulty";
const string LEVEL_KEY = "level_unlocked_";

public static void SetMasterVolume (float volume) {
	if (volume > 0f < 1f) {
		PlayerPrefs.SetFloat (MASTER_VOLUME_KEY, volume);
	} else {
		Debug.LogError ("Master volume out of range");
	}
}

public static float GetMasterVolume () {
	return PlayerPrefs.GetFloat (MASTER_VOLUME_KEY);
}

public static void UnlockLevel (int level) {
	if (level <= Application.levelCount - 1) {
		PlayerPrefs.SetInt (LEVEL_KEY + level.ToString (), 1);
		//This acts like a boolen so 1 = true.
	} else {
		Debug.LogError ("Trying to unlock level not in build order");
	}
}

}


is incorrect, it needs to be:

[code]if (volume > 0f && volume < 1f)[/code]

is incorrect, it needs to be:

Thanx for that… I also misread where the error was. I had an error in line 24, well actually 2 of them. Fixed it and then saw this other error pop in. Too much time spent researching one thing made me blind to the facts of another.

Privacy & Terms