By using the ternary operator ?:
perClick = PlayerPrefs.HasKey("clickpoints") ? PlayerPrefs.GetFloat("clickpoints") : 2.0f;
I want to assign to the "perClick" variable the float stored in the PlayerPref, if the condition evaluates to True, or, if it evaluates to False, I want to set "perClick" to 2. However, if False, I also want to do PlayerPrefs.SetFloat("clickpoints, 2.0f). Is it possible to add more than one statement to the last option?
perClick = PlayerPrefs.GetFloat("clickpoints", 2.0f);Just use the default value version of the function. docs.unity3d.com/ScriptReference/PlayerPrefs.GetFloat.html If you want to force the preferences to have the value callPlayerPrefs.SetFloat("clickpoints, perClick);too. IfperClickis a property you could set the preferences whenever it changes in the setter.if then elseconstruct instead. It will make your code easier to read and won't require you to curse and give up. The two parts of a ternary are expressions not statements. The way they work isvar result=someCondition ? valueIfTrue : valueIfFalse;. There's no room there for a statement like an unrelated function calll