private void LoadBuiltInCredentials() { foreach (TextAsset creds in builtInCredentials) { DataTarget target = new DataTarget(); target.credentials = TargetCredentials.CreateFromJSON(creds.text); Debug.Log(target.credentials.label); dataTargets.Add(target.credentials.label, target); } }
private void DetectCredentialsOnDisk() { string authDirectory = Application.persistentDataPath + "/Auth/"; var credentialFiles = Directory.GetFiles(authDirectory, "mysql*"); Debug.Log(credentialFiles.Length); if (credentialFiles.Length > 0) { foreach (var filepath in credentialFiles) { Debug.Log("Loading credentials from: " + filepath); string line; string json = ""; using (StreamReader reader = new StreamReader(filepath)) { while ((line = reader.ReadLine()) != null) { json += line; } } DataTarget target = new DataTarget(); target.credentials = TargetCredentials.CreateFromJSON(json); dataTargets.Add(target.credentials.label, target); } } else { mysqlCred = Instantiate(Resources.Load("MySQLAuthCanvas", typeof(GameObject))) as GameObject; mysqlCred.SetActive(true); if (UnityEngine.EventSystems.EventSystem.current == null) { eventSystem = Instantiate(Resources.Load("MySQLEventSystem", typeof(GameObject))) as GameObject; eventSystem.SetActive(true); } var inputFields = mysqlCred.GetComponentsInChildren <InputField>(); labelInputField = inputFields[0]; dbSecKeyInputField = inputFields[1]; dbNameField = inputFields[2]; tableNameField = inputFields[3]; userNameField = inputFields[4]; passwordField = inputFields[5]; dbURLField = inputFields[6]; connectButton = GameObject.Find("MySQLConnectButton"); Button button = connectButton.GetComponent <Button>(); button.onClick.AddListener(() => Toggle_AuthConnect()); } }