- Home /
Various obsolete warnings in cs and js scripts in unity car tutorial
As the title says, I'm getting obsolete warnings in the unity car tutorial. Here are the warnings.
C# Warnings
Assets/Scripts/CSharpScripts/BirdsBehaviour.cs(13,36): warning CS0618: UnityEngine.QualitySettings.currentLevel' is obsolete:
Use GetQualityLevel and SetQualityLevel'
Assets/Scripts/CSharpScripts/BirdsBehaviour.cs(13,64): warning CS0618: UnityEngine.QualityLevel' is obsolete:
See QualitySettings.names, QualitySettings.SetQualityLevel, and QualitySettings.GetQualityLevel'
Assets/Scripts/CSharpScripts/EffectController.cs(13,36): warning CS0618: UnityEngine.QualitySettings.currentLevel' is obsolete:
Use GetQualityLevel and SetQualityLevel'
Assets/Scripts/CSharpScripts/EffectController.cs(13,64): warning CS0618: UnityEngine.QualityLevel' is obsolete:
See QualitySettings.names, QualitySettings.SetQualityLevel, and QualitySettings.GetQualityLevel'
Javascript Warnings
Assets/Scripts/JavaScripts/FPSCounter.js(54,113): BCW0012: WARNING: 'UnityEngine.QualitySettings.currentLevel' is obsolete. Use GetQualityLevel and SetQualityLevel
Assets/Scripts/JavaScripts/PerformanceTweak.js(181,36): BCW0012: WARNING: 'UnityEngine.QualitySettings.currentLevel' is obsolete. Use GetQualityLevel and SetQualityLevel
Assets/Scripts/JavaScripts/PerformanceTweak.js(186,36): BCW0012: WARNING: 'UnityEngine.QualitySettings.currentLevel' is obsolete. Use GetQualityLevel and SetQualityLevel
Assets/Scripts/JavaScripts/PerformanceTweak.js(190,28): BCW0012: WARNING: 'UnityEngine.QualitySettings.currentLevel' is obsolete. Use GetQualityLevel and SetQualityLevel
Can someone help me fix these? I want to adapt this tutorial to my car racing game, but I feel I cannot adapt it fully if I'm getting these warnings. If someone could help me that would be great.
Edit: Here is more specific information. I know these warnings are a repeat. I just wanted to post them anyway, just in case.
Here is where the problem starts in BirdsBehaviour.cs
void Start()
{
if(QualitySettings.currentLevel < QualityLevel.Good)
{
this.enabled = false;
return;
}
birdTimer = Random.Range(2,5);
}
Here is where the problem is happening in EffectController.cs
void Update()
{
if(QualitySettings.currentLevel < QualityLevel.Good)
{
if (generate2dReflection)
generate2dReflection.enabled = false;
if (glowEffect)
glowEffect.enabled = false;
if (motionBlur)
motionBlur.enabled = false;
if (colorCorrection)
colorCorrection.enabled = false;
}
else
{
if (generate2dReflection)
generate2dReflection.enabled = true;
if (glowEffect)
glowEffect.enabled = true;
if (motionBlur)
motionBlur.enabled = true;
if (colorCorrection)
colorCorrection.enabled = true;
}
}
Here is where the problem is happening in FPSCounter.js
function OnGUI()
{
GUI.Box(new Rect(Screen.width-160, 10, 150, 40), fps.ToString("f2") + " | QSetting: " + QualitySettings.currentLevel);
}
Here is where the problem is happening in PerformanceTweak.js
{
if(QualitySettings.currentLevel > QualityLevel.Fastest)
QualitySettings.DecreaseLevel();
}
else if(fps > highFPS)
{
if(QualitySettings.currentLevel < QualityLevel.Fantastic)
QualitySettings.IncreaseLevel();
}
if(QualitySettings.currentLevel < QualityLevel.Good)
Aaand?!...
The tutorial is kinda old so some things have changed in the API. The warnings even tell you exactly what you should use ins$$anonymous$$d. Do you even have a problem with the warnings? As long as there're no errors it's fine.
If you don't like the warnings, replace them with the new version like mentioned in the warning. You know the filename, the line number and the column number. You know which variable / property / function is obsolete and which one you should use ins$$anonymous$$d.
$$anonymous$$ost Unity users (like myself) don't even have this tutorial so what should we do...
Please don't be rude. I don't appreciate it. I'm saying this because I need the help, and yes the warnings bug me. I wouldn't be posting in here otherwise. I'm also not going to ignore the warnings.
I should've posted in my original message that I've unsuccessfully tried fixing it, sorry about that. I'll update the question appropriately.
Edit: forgot to add that I'm still relatively new to program$$anonymous$$g.
Answer by Bunny83 · Mar 25, 2012 at 12:51 PM
The QualityLevel enum is obsolete.
[Obsolete("See QualitySettings.names, QualitySettings.SetQualityLevel, and QualitySettings.GetQualityLevel")]
public enum QualityLevel
{
Fastest, // 0
Fast, // 1
Simple, // 2
Good, // 3
Beautiful, // 4
Fantastic // 5
}
The obsolete warning says: "See QualitySettings.names, QualitySettings.SetQualityLevel, and QualitySettings.GetQualityLevel".
If the levels are still the same (maybe there will be different levels in the future), this line would be:
if(QualitySettings.GetQualityLevel() < 3)
// instead of
if(QualitySettings.currentLevel < QualityLevel.Good)
The other occurrences should be no problems now.