using UnityEngine;
using System.Collections;
using System.Linq;
using UnityEngine.UI;
public class OptionsFormScript : MonoBehaviour {
#region Properties
///
/// Gets the value of the 'Mines' field
///
public int Mines {
get { return int.Parse(Get("Text", "Mines").text); }
}
///
/// Gets the value of the 'Width' field
///
public int FieldWidth {
get { return int.Parse(Get("Text", "FieldWidth").text); }
}
///
/// Gets the value of the 'Height' field
///
public int FieldHeight {
get { return int.Parse(Get("Text", "FieldHeight").text); }
}
#endregion
///
/// Gets the field with name and parent
///
/// Name of the object
/// Name of the parent of the object
///
private Text Get(string name, string parentName) {
var texts =
this.GetComponentsInChildren()
.Where(text => text.name == name && text.transform.parent.transform.parent.name == parentName);
if (texts.Count() == 1)
return texts.First();
string temp = " text field found named " + name + " of parent " + parentName;
if (!texts.Any())
throw new MissingComponentException("No" + temp);
throw new MissingComponentException("Multiple" + temp);
}
}