public DebugLayout ValueSlider(FieldPresentSettings name, float min, float max, IValueRW <float> val, bool wholeNumbers = false,
                                   DebugLayoutOptions opts = default(DebugLayoutOptions))
    {
        var slider = NamedElementOrLayouted <Slider>(name, factory.slider, opts);

        slider.minValue     = min;
        slider.maxValue     = max;
        slider.wholeNumbers = wholeNumbers;
        slider.value        = val.value;

        var input = slider.GetComponentInChildren <InputField>();

        input.text = val.value.ToString();
        input.onValueChanged.AddListener(i =>
        {
            slider.value = float.Parse(i);
            val.value    = slider.value;
        });
        slider.onValueChanged.AddListener(i =>
        {
            val.value  = i;
            input.text = i.ToString();
        });

        return(this);
    }
    public DebugLayout InputField(FieldPresentSettings name, IValueRW <string> val)
    {
        var input = NamedElementOrLayouted <InputField>(name, factory.stringInputPrefab);

        input.text = val.value;
        input.onValueChanged.AddListener(i => { val.value = i; });
        return(this);
    }
    public DebugLayout Toggle(FieldPresentSettings name, IValueRW <bool> value)
    {
        var obj = InstantiateInLayout(factory.buttonTogglePrefab).GetComponentInChildren <Toggle>();

        obj.GetComponentInChildren <Text>().text = name.name;
        obj.isOn = value.value;
        obj.onValueChanged.AddListener(new UnityAction <bool>(i => { value.value = i; }));
        return(this);
    }
    public DebugLayout Selector(FieldPresentSettings name, IList <string> options, ICellRW <string> value
                                , DebugLayoutOptions opts = default(DebugLayoutOptions))
    {
        Dropdown selector = NamedElementOrLayouted <Dropdown>(name, factory.dropdownPrefab, opts).GetComponentInChildren <Dropdown>();

        selector.options = options.Select(elemName => new Dropdown.OptionData(elemName)).ToList();
        value.Bind(v => selector.value = options.IndexOf(v));
        selector.onValueChanged.AddListener(new UnityAction <int>(i =>
        {
            value.value = options[i];
        }));
        return(this);
    }
    public DebugLayout NumberSelector(FieldPresentSettings name, IValueRW <float> value, DebugMenuFloatRange range = null, DebugLayoutOptions opts = default(DebugLayoutOptions))
    {
        var attr = range;

        if (attr != null)
        {
            var input = ValueSlider(name, attr.min, attr.max, value, false, opts);
        }
        else
        {
            var input = NamedElementOrLayouted <InputField>(name, factory.stringInputPrefab, opts);
            input.contentType = UnityEngine.UI.InputField.ContentType.DecimalNumber;
            input.text        = value.value.ToString();
            input.onValueChanged.AddListener(new UnityAction <string>(i => value.value = float.Parse(i)));
        }
        return(this);
    }
    public T NamedElementOrLayouted <T>(FieldPresentSettings name, RectTransform prefab, DebugLayoutOptions options = default(DebugLayoutOptions))
        where T : MonoBehaviour
    {
        RectTransform elem = null;

        if (string.IsNullOrEmpty(name.name))
        {
            elem = InstantiateInLayout(prefab, options);
        }
        else if (name.type == NamingType.Lined)
        {
            elem = LinedNameElement(name.name, prefab, options);
        }
        else if (name.type == NamingType.Boxed)
        {
            elem = BoxedNameElement(name.name, prefab, options);
        }
        return(elem.GetComponentInChildren <T>());
    }
 public DebugLayout ValueSlider(FieldPresentSettings name, int min, int max, IValueRW <int> val,
                                DebugLayoutOptions opts = default(DebugLayoutOptions))
 {
     return(ValueSlider(name, min, max, val.MapValue(i => (float)i, f => (int)f), true, opts));
 }
 public static FieldPresentSettings WithNaming(this FieldInfo field, NamingType type)
 {
     return(FieldPresentSettings.WithName(field.Name, type));
 }
 public DebugLayout EnumSelector(FieldPresentSettings name, Type enumType, ICellRW <object> value,
                                 DebugLayoutOptions opts = default(DebugLayoutOptions), ExcudeEnumNameInSelector exclude = null)
 {
     return(Selector(name, Enum.GetNames(enumType).Where(n => exclude == null || exclude.name.Contains(n) == false).ToList(),
                     value.MapRW(v => v.ToString(), s => Enum.Parse(enumType, s)), opts));
 }
 public DebugLayout EnumSelector <T>(FieldPresentSettings name, ICellRW <T> value, DebugLayoutOptions opts = default(DebugLayoutOptions))
 {
     return(Selector(name, Enum.GetNames(typeof(T)),
                     value.MapRW(v => v.ToString(), s => (T)Enum.Parse(typeof(T), s)), opts));
 }