- Home /
Quality Settings To Turn On Object
Hello, I am trying to turn on an object based off of the quality setting, I have this script:
var object1 : GameObject;
function Awake ()
{
QualitySettings.GetQualityLevel();
}
function Update ()
{
if (QualityLevel.Fastest)
{
object1.gameObject.SetActive(true);
}
}
And I get no errors with it, even during runtime, however it is not working at all. I dont understand where I am going wrong.
If you want to learn about scripting, please follow a tutorial. For instance Unity provides a scripting tutorial at
I already know basic scripting, but Im having an issue with a script which is why I came here with my problem. Telling me to learn scripting kindof just defeats the purpose of all of Unity Answers.
if( QualitySettings.LevelName == QualityLevel.Fastest){
}
Try this, I don't know if it will work but it is worth a try.
EDIT : I usually run a debug.log() or print() to see if the line of code within the brackets are getting called. Pretty handy in the early stage of your project. After you finish the script you usually want to then delete all those debug.log and print() from your script to improve preformance.
Well I tried using that but realized that the level name of the quality setting would equate to the quality level, so ins$$anonymous$$d I used: (QualitySettings.currentLevel = QualityLevel.Fastest)
and got back these errors BCE0044: expecting ), found '='. BCE0043: Unexpected token: ).
So I tried using this ins$$anonymous$$d: if (QualitySettings.LevelName("Fastest"))
and got this long error: $$anonymous$$issing$$anonymous$$ethodException: UnityEngine.QualitySettings.LevelName Boo.Lang.Runtime.DynamicDispatching.$$anonymous$$ethodDispatcherFactory.ProduceExtensionDispatcher () Boo.Lang.Runtime.DynamicDispatching.$$anonymous$$ethodDispatcherFactory.Create () Boo.Lang.Runtime.RuntimeServices.DoCreate$$anonymous$$ethodDispatcher (System.Object target, System.Type targetType, System.String name, System.Object[] args) Boo.Lang.Runtime.RuntimeServices.Create$$anonymous$$ethodDispatcher (System.Object target, System.String name, System.Object[] args) Boo.Lang.Runtime.RuntimeServices+c_AnonStorey15.<>m_9 () Boo.Lang.Runtime.DynamicDispatching.DispatcherCache.Get (Boo.Lang.Runtime.DynamicDispatching.Dispatcher$$anonymous$$ey key, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cache$$anonymous$$eyName, System.Type[] cache$$anonymous$$eyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object[] args, System.String cache$$anonymous$$eyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.Invoke (System.Object target, System.String name, System.Object[] args) UnityScript.Lang.UnityRuntimeServices.Invoke (System.Object target, System.String name, System.Object[] args, System.Type scriptBaseType)
Answer by Hexer · Jul 26, 2015 at 03:18 PM
That is strange, I have played with the code for a while with use of the unity reference and I made this script. (I made some mistake with saying LevelName, LevelName is not a member of QualitySettings so it didnt work. It should have been currentLevel. and you forgot to add another "=" ____1x"=" means Is. while 2x"=" mean is Equal to)
using UnityEngine;
using System.Collections;
public class Test : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (QualitySettings.currentLevel == QualityLevel.Fastest) {
Application.LoadLevel ("1");
} else
Application.LoadLevel ("2");
}
}
When I build and run this test project and put the quality to fastest. it would go to Apllication.LoadLevel("1"); and if some other quality was chosen, it would go to Application.LoadLevel("2");.
The same concept can also be applied to your script.
if (QualitySettings.currentLevel == QualityLevel.Fastest) {
object1.gameObject.SetActive(true);
}
I thought I had tried that before but it didnt work, retried it and it did, idk, but thank you for the help!