public DebugLayout Label(ICell <string> name, int fontSize = 40) { var t = InstantiateInLayout(factory.titlePrefab, DebugLayoutOptions.Fixed(fontSize + 6)).GetComponentInChildren <Text>(); t.resizeTextForBestFit = true; t.resizeTextMaxSize = (int)fontSize; connections += name.Bind(n => t.text = n); return(this); }
public DebugLayout DrawAllFields(object obj, float selectorSize = 65, NamingType naming = NamingType.Lined, Func <object, FieldInfo, DebugLayout, bool> customFactory = null) { if (obj == null) { Label("null", 40); return(this); } var opts = DebugLayoutOptions.Fixed(selectorSize); foreach (var fieldInfo in obj.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy)) { if (customFactory != null && customFactory(obj, fieldInfo, this)) { continue; } if (fieldInfo.HasAttribute <ExcudeFromDebugMenu>()) { continue; } if (fieldInfo.FieldType.IsEnum) { EnumSelector(fieldInfo.WithNaming(naming), fieldInfo.FieldType, obj.ReflectionFieldToRW <object>(fieldInfo.Name), exclude: fieldInfo.GetCustomAttribute <ExcudeEnumNameInSelector>(), opts: opts); } else if (fieldInfo.FieldType == typeof(string)) { var input = NamedElementOrLayouted <InputField>(fieldInfo.WithNaming(naming), factory.stringInputPrefab, opts); input.text = (string)fieldInfo.GetValue(obj); input.onValueChanged.AddListener(new UnityAction <string>(i => { fieldInfo.SetValue(obj, i); })); } else if ( fieldInfo.FieldType == typeof(long)) { var attr = fieldInfo.GetCustomAttributes <DebugMenuIntRange>().FirstOrDefault(); NumberSelector(fieldInfo.WithNaming(naming), obj.ReflectionFieldToRW <long>(fieldInfo).MapValue(i => (int)i, i => (long)i), attr, opts); } else if (fieldInfo.FieldType == typeof(int)) { var attr = fieldInfo.GetCustomAttributes <DebugMenuIntRange>().FirstOrDefault(); NumberSelector(fieldInfo.WithNaming(naming), obj.ReflectionFieldToRW <int>(fieldInfo), attr, opts); } else if (fieldInfo.FieldType == typeof(bool)) { var input = NamedElementOrLayouted <Toggle>(fieldInfo.WithNaming(naming), factory.togglePrefab, opts); input.isOn = (bool)fieldInfo.GetValue(obj); input.onValueChanged.AddListener(new UnityAction <bool>(i => { fieldInfo.SetValue(obj, i); })); } else if (fieldInfo.FieldType.IsClass) { if (type == LayoutType.Flow) { FlowDelimiterCut(); } Title(fieldInfo.Name, type == LayoutType.Flow ? DebugLayoutOptions.Fixed(1000) : opts); if (type == LayoutType.Flow) { FlowDelimiterCut(); } DrawAllFields(fieldInfo.GetValue(obj), selectorSize, naming, customFactory); if (type == LayoutType.Flow) { FlowDelimiterCut(); } else { Delimiter(); } } } // var delimiter = Instantiate(factory.optionPrefab, rect); // delimiter.GetComponentInChildren<Text>().text = ""; // delimiter.sizeDelta = new Vector2(100, 20); return(this); }
public DebugLayout FlowDelimiterCut() { InstantiateInLayout(factory.delimiterPrefab, DebugLayoutOptions.Fixed(2000, 0.001f)); return(this); }
public DebugLayout Delimiter(float size = 50) { InstantiateInLayout(factory.delimiterPrefab, DebugLayoutOptions.Fixed(size)); return(this); }