void DrawNullMaterial() { if (NezImGui.CenteredButton("Create Material", 0.5f, ImGui.GetStyle().IndentSpacing * 0.5f)) { var material = new Material(); SetValue(material); _inspectors = TypeInspectorUtils.GetInspectableProperties(material); } }
public override void Initialize() { base.Initialize(); // figure out which fields and properties are useful to add to the inspector var fields = ReflectionUtils.GetFields(_valueType); foreach (var field in fields) { if (!field.IsPublic && !field.IsDefined(typeof(InspectableAttribute))) { continue; } var inspector = TypeInspectorUtils.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; } var isPropertyUndefinedOrPublic = !prop.CanWrite || (prop.CanWrite && prop.SetMethod.IsPublic); if ((!prop.GetMethod.IsPublic || !isPropertyUndefinedOrPublic) && !prop.IsDefined(typeof(InspectableAttribute))) { continue; } var inspector = TypeInspectorUtils.GetInspectorForType(prop.PropertyType, _target, prop); if (inspector != null) { inspector.SetStructTarget(_target, this, prop); inspector.Initialize(); _inspectors.Add(inspector); } } }
public override void Initialize() { base.Initialize(); var effect = GetValue <Effect>(); _name += $" ({effect.GetType().Name})"; var inspectors = TypeInspectorUtils.GetInspectableProperties(effect); foreach (var inspector in inspectors) { // we dont need the Name field. It serves no purpose. if (inspector.Name != "Name") { _inspectors.Add(inspector); } } }
public override void Initialize() { base.Initialize(); _wantsIndentWhenDrawn = true; var material = GetValue <Material>(); if (material == null) { return; } // fetch our inspectors and let them know who their parent is _inspectors = TypeInspectorUtils.GetInspectableProperties(material); // if we are a Material<T>, we need to fix the duplicate Effect due to the "new T effect" if (ReflectionUtils.IsGenericTypeOrSubclassOfGenericType(material.GetType())) { var didFindEffectInspector = false; for (var i = 0; i < _inspectors.Count; i++) { var isEffectInspector = _inspectors[i] is EffectInspector; if (isEffectInspector) { if (didFindEffectInspector) { _inspectors.RemoveAt(i); break; } didFindEffectInspector = true; } } } }