diff --git a/Assets/Plugins/CandyCoded.Forms/Scripts/Form.cs b/Assets/Plugins/CandyCoded.Forms/Scripts/Form.cs index 395c7ab..bf98452 100644 --- a/Assets/Plugins/CandyCoded.Forms/Scripts/Form.cs +++ b/Assets/Plugins/CandyCoded.Forms/Scripts/Form.cs @@ -47,11 +47,18 @@ private void Update() } + public IEnumerable GetChildFormFields() + { + + return gameObject.GetComponentsInChildren() + .Where(field => field.name != "" && field.parentForm.Equals(this)); + + } + public Dictionary GetFormRawValues() { - return gameObject.GetComponentsInChildren().Where(field => field.name != "") - .ToDictionary(field => field.name, field => field.value); + return GetChildFormFields().ToDictionary(field => field.name, field => field.value); } @@ -74,7 +81,7 @@ public Dictionary GetFormRawValues() public void LoadFormRawValues(Dictionary values) { - var formFields = gameObject.transform.GetComponentsInChildren(); + var formFields = GetChildFormFields(); foreach (var value in values) { @@ -98,7 +105,7 @@ public void LoadFormRawValues(Dictionary values) public void LoadFormValues(T values) { - var formFields = gameObject.transform.GetComponentsInChildren(); + var formFields = GetChildFormFields(); foreach (var fieldInfo in values.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance)) { diff --git a/Assets/Plugins/CandyCoded.Forms/Scripts/FormField.cs b/Assets/Plugins/CandyCoded.Forms/Scripts/FormField.cs index a87c8c4..990ca6a 100644 --- a/Assets/Plugins/CandyCoded.Forms/Scripts/FormField.cs +++ b/Assets/Plugins/CandyCoded.Forms/Scripts/FormField.cs @@ -21,6 +21,8 @@ public class FormField : MonoBehaviour private object _value; + public Form parentForm { get; private set; } + public new string name { get @@ -106,6 +108,13 @@ public object value } } + private void Awake() + { + + parentForm = gameObject.GetComponentInParent
(); + + } + public void SetStringValue(string value) {