Question by
hyeqt100 · Aug 06, 2018 at 05:09 PM ·
parentinputfieldchildreninputmanager
Input field with children input fields?
How can I go about saving a set of flash cards (terms and definitions) according to the parent input field, which is the subject for the terms? Do I use an On Value Changed for the parent? I'm not sure how to go about saving each set of terms as well since PlayerPrefs doesn't have subfolders for things like this. This is what I have so far for the terms/definitions:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEditor;
using UnityEngine.SceneManagement;
public class CreateSubject : MonoBehaviour
{
public InputField subjectname;
List<string> textFromMyInputs = new List<string>();
void GetAllTextFromInputFields()
{
foreach (InputField inputField in gameObject.GetComponentsInChildren<InputField>())
{
foreach (Text text in inputField.GetComponentsInChildren<Text>())
{
if (text.gameObject.name != "Placeholder")
textFromMyInputs.Add(text.text);
}
}
foreach (string s in textFromMyInputs)
{
Debug.Log(s);
}
}
}
Comment