I am trying to add a dropdown to a scene where the user selects an option and it updates the playerprefs and when app restarts, the selected option on the dropdown should be the one previously selected by the user.
The code I have come up with so far is as follows.
public Dropdown mViewerTypeDropDown;
void Start () {
mDebug = (LRDebug)mScriptHolder.GetComponent<LRDebug> ();
mScriptHolder=GameObject.Find ("ScriptHolder");
mViewerTypeDropDown.captionText.text = PlayerPrefs.GetString ("Viewer Type","Generic Cardboard (Default)");
}
//The Function attached to onvaluechanged listner
public void ViewerTypeChanged(int value)
{
mViwerTypeChange = value;
switch (mViwerTypeChange) {
case 0:
mViewerType = "Generic Cardboard (Default)";
break;
case 1:
mViewerType="VR ONE (Zeiss)";
break;
case 2:
mViewerType="VR Goggles (Merge)";
break;
case 3:
mViewerType="C1-Glass (Go4D)";
break;
case 4:
mViewerType="Cardboard v1 (Google)";
break;
}
PlayerPrefs.SetString("Viewer Type",mViewerType);
PlayerPrefs.Save ();
}
This seems logically right to me but I am not sure of what I am missing here. And to be further clear I have made the attached method a dynamic one in the editor as follows
I have searched a lot but as this dropdown option is a new one There are not many examples out yet. So as a unity newbie I cannot seem to work this one out. If anyone could help me with this it will be a great help. thank you