public override void initialize(Table table, Skin skin, float leftCellWidth) { // add a header var label = table.add(createNameLabel(table, skin)).setColspan(2).getElement <Label>(); label.setStyle(label.getStyle().clone()).setFontColor(new Color(228, 228, 76)); table.row().setPadLeft(15); // figure out which fiedls and properties are useful to add to the inspector var fields = ReflectionUtils.getFields(_valueType); foreach (var field in fields) { if (!field.IsPublic && IEnumerableExt.count(field.GetCustomAttributes <InspectableAttribute>()) == 0) { continue; } var inspector = getInspectorForType(field.FieldType, _target, field); if (inspector != null) { inspector.setStructTarget(_target, this, field); inspector.initialize(table, skin, leftCellWidth); _inspectors.Add(inspector); table.row().setPadLeft(15); } } var properties = ReflectionUtils.getProperties(_valueType); foreach (var prop in properties) { if (!prop.CanRead || !prop.CanWrite) { continue; } if ((!prop.GetMethod.IsPublic || !prop.SetMethod.IsPublic) && IEnumerableExt.count(prop.GetCustomAttributes <InspectableAttribute>()) == 0) { continue; } var inspector = getInspectorForType(prop.PropertyType, _target, prop); if (inspector != null) { inspector.setStructTarget(_target, this, prop); inspector.initialize(table, skin, leftCellWidth); _inspectors.Add(inspector); table.row().setPadLeft(15); } } }
public override void initialize(Table table, Skin skin, float leftCellWidth) { // we either have a getter that gets a Material or an Effedt var effect = _valueType == typeof(Material) ? getValue <Material>().effect : getValue <Effect>(); if (effect == null) { return; } // add a header and indent our cells table.add(effect.GetType().Name).setColspan(2).getElement <Label>().setFontColor(new Color(228, 228, 76)); table.row().setPadLeft(15); // figure out which properties are useful to add to the inspector var effectProps = ReflectionUtils.getProperties(effect.GetType()); foreach (var prop in effectProps) { if (prop.DeclaringType == typeof(Effect)) { continue; } if (!prop.CanRead || !prop.CanWrite || prop.Name == "Name") { continue; } if ((!prop.GetMethod.IsPublic || !prop.SetMethod.IsPublic) && IEnumerableExt.count(prop.GetCustomAttributes <InspectableAttribute>()) == 0) { continue; } var inspector = getInspectorForType(prop.PropertyType, effect, prop); if (inspector != null) { inspector.setTarget(effect, prop); inspector.initialize(table, skin, leftCellWidth); _inspectors.Add(inspector); table.row().setPadLeft(15); } } table.row(); }
public override void initialize( ) { // add a header // figure out which fiedls and properties are useful to add to the inspector var fields = ReflectionUtils.getFields(_valueType); foreach (var field in fields) { if (!field.IsPublic && IEnumerableExt.count(field.GetCustomAttributes <InspectableAttribute>()) == 0) { continue; } var inspector = getInspectorForType(field.FieldType, _target, field); if (inspector != null) { inspector.setStructTarget(_target, this, field); inspector.initialize(); _inspectors.Add(inspector); } } var properties = ReflectionUtils.getProperties(_valueType); foreach (var prop in properties) { if (!prop.CanRead || !prop.CanWrite) { continue; } if ((!prop.GetMethod.IsPublic || !prop.SetMethod.IsPublic) && IEnumerableExt.count(prop.GetCustomAttributes <InspectableAttribute>()) == 0) { continue; } var inspector = getInspectorForType(prop.PropertyType, _target, prop); if (inspector != null) { inspector.setStructTarget(_target, this, prop); inspector.initialize(); _inspectors.Add(inspector); } } }
public override void initialize() { base.initialize(); // we either have a getter that gets a Material or an Effect var effect = _valueType == typeof(Material) ? getValue <Material>().effect : getValue <Effect>(); if (effect == null) { return; } Debug.log($"name was {_name}"); _name = effect.GetType().Name; // figure out which properties are useful to add to the inspector var effectProps = ReflectionUtils.getProperties(effect.GetType()); foreach (var prop in effectProps) { if (prop.DeclaringType == typeof(Effect)) { continue; } if (!prop.CanRead || !prop.CanWrite || prop.Name == "Name") { continue; } if ((!prop.GetMethod.IsPublic || !prop.SetMethod.IsPublic) && IEnumerableExt.count(prop.GetCustomAttributes <InspectableAttribute>()) == 0) { continue; } var inspector = TypeInspectorUtils.getInspectorForType(prop.PropertyType, effect, prop); if (inspector != null) { inspector.setTarget(effect, prop); inspector.initialize(); _inspectors.Add(inspector); } } }
/// <summary> /// fetches all the relevant AbstractTypeInspectors for target including fields, properties and methods. /// </summary> /// <param name="target"></param> /// <returns></returns> public static List <AbstractTypeInspector> getInspectableProperties(object target) { var props = new List <AbstractTypeInspector>(); var targetType = target.GetType(); var fields = ReflectionUtils.getFields(targetType); foreach (var field in fields) { if (!field.IsPublic && IEnumerableExt.count(field.GetCustomAttributes <InspectableAttribute>()) == 0) { continue; } if (field.IsInitOnly) { continue; } // skip enabled which is handled elsewhere if (field.Name == "enabled" || field.Name == "entity") { continue; } var inspector = getInspectorForType(field.FieldType, target, field); if (inspector != null) { inspector.setTarget(target, field); inspector.initialize(); props.Add(inspector); } } var properties = ReflectionUtils.getProperties(targetType); foreach (var prop in properties) { if (!prop.CanRead || !prop.CanWrite) { continue; } if ((!prop.GetMethod.IsPublic || !prop.SetMethod.IsPublic) && IEnumerableExt.count(prop.GetCustomAttributes <InspectableAttribute>()) == 0) { continue; } // skip Component.enabled which is handled elsewhere if (prop.Name == "enabled" || prop.Name == "entity") { continue; } var inspector = getInspectorForType(prop.PropertyType, target, prop); if (inspector != null) { inspector.setTarget(target, prop); inspector.initialize(); props.Add(inspector); } } var methods = ReflectionUtils.getMethods(targetType); foreach (var method in methods) { var attr = method.GetCustomAttribute <InspectorCallableAttribute>(); if (attr == null) { continue; } if (!MethodInspector.areParametersValid(method.GetParameters())) { continue; } var inspector = new MethodInspector(); inspector.setTarget(target, method); inspector.initialize(); props.Add(inspector); } return(props); }