bool ParseArguments(string[] args) { // Allow local preferences to be set from the command line try { for (int i = 0; i < args.Length; i = i + 2) { if (args[i].StartsWith("-")) { String setting = args[i].Substring(1); String value = args[i + 1]; Console.WriteLine("Using setting: " + setting + " " + value); LocalPrefs.Set(setting, value); } else { // This is a DLL file to open fileToOpen = args[i]; } } return(true); } catch { Console.WriteLine("Error in arguments: specify '-setting value'"); return(false); } }
void Start() { boolsUI.clearAllButton.onClick.AddListener(() => { for (int i = 0; i < bools.Count; i++) { DestroyBool(bools[i]); } }); boolsUI.addButton.onClick.AddListener(() => { int keysCount = bools.Count; string newItemKey = "New " + "Boolean" + " "; while (LocalPrefs.HasKey <bool>(newItemKey + keysCount)) { keysCount++; } string newKey = newItemKey + keysCount; LocalPrefs.Set(newKey, false); InstatiateBoolUI(newKey); }); string[] allBooleans = LocalPrefs.AllKeys <bool>(); bools = new List <BoolUI>(allBooleans.Length); for (int i = 0; i < allBooleans.Length; i++) { bools.Add(InstatiateBoolUI(allBooleans[i])); } SetBoolListeners(); }
void RandomLocalPrefs() { localPrefs = new float[randomPrefsCount]; LocalPrefs.SetInt("RandomPrefsCount", randomPrefsCount); for (int i = 0; i < randomPrefsCount; i++) { localPrefs[i] = LocalPrefs.Set <float>("RandomFloat" + i, UnityEngine.Random.Range(0, 100000)); } }
void SetBoolListeners() { for (int i = 0; i < bools.Count; i++) { int m_i = i; var boolUI = bools[m_i]; bools[i].input.onEndEdit.RemoveAllListeners(); bools[i].toggle.onValueChanged.RemoveAllListeners(); bools[i].removeButton.onClick.RemoveAllListeners(); // On Input field bools[i].input.onEndEdit.AddListener((s) => { if (!LocalPrefs.HasKey <bool>(s)) { boolUI.key = LocalPrefs.ChangeKey <bool>(boolUI.key, s); bools[m_i] = boolUI; } else if (s != boolUI.key) { bools[m_i].input.text = boolUI.key; Debug.Log("Boolean with key \"" + s + "\" is already presented in preferences."); } SetBoolListeners(); }); // On Toggle bools[i].toggle.onValueChanged.AddListener((b) => { LocalPrefs.Set(boolUI.key, b); SetBoolListeners(); }); // On Remove button bools[i].removeButton.onClick.AddListener(() => { DestroyBool(boolUI); SetBoolListeners(); }); } }