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;
                    }
                }
            }
        }
 private void DrawNullMaterial()
 {
     if (NezImGui.CenteredButton("Create Material", 0.5f, ImGui.GetStyle().IndentSpacing * 0.5f))
     {
         Material material = new Material();
         SetValue(material);
         _inspectors = TypeInspectorUtils.GetInspectableProperties(material);
     }
 }
Пример #3
0
        public override void Initialize()
        {
            base.Initialize();

            // figure out which fields and properties are useful to add to the inspector
            IEnumerable <FieldInfo> fields = ReflectionUtils.GetFields(_valueType);

            foreach (FieldInfo field in fields)
            {
                if (!field.IsPublic && !field.IsDefined(typeof(InspectableAttribute)))
                {
                    continue;
                }

                AbstractTypeInspector inspector = TypeInspectorUtils.GetInspectorForType(field.FieldType, _target, field);
                if (inspector != null)
                {
                    inspector.SetStructTarget(_target, this, field);
                    inspector.Initialize();
                    _inspectors.Add(inspector);
                }
            }

            IEnumerable <PropertyInfo> properties = ReflectionUtils.GetProperties(_valueType);

            foreach (PropertyInfo prop in properties)
            {
                if (!prop.CanRead || !prop.CanWrite)
                {
                    continue;
                }

                bool isPropertyUndefinedOrPublic = !prop.CanWrite || (prop.CanWrite && prop.SetMethod.IsPublic);
                if ((!prop.GetMethod.IsPublic || !isPropertyUndefinedOrPublic) &&
                    !prop.IsDefined(typeof(InspectableAttribute)))
                {
                    continue;
                }

                AbstractTypeInspector inspector = TypeInspectorUtils.GetInspectorForType(prop.PropertyType, _target, prop);
                if (inspector != null)
                {
                    inspector.SetStructTarget(_target, this, prop);
                    inspector.Initialize();
                    _inspectors.Add(inspector);
                }
            }
        }
Пример #4
0
        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 && IEnumerableExt.count(field.GetCustomAttributes <InspectableAttribute>()) == 0)
                {
                    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;
                }

                if ((!prop.GetMethod.IsPublic || !prop.SetMethod.IsPublic) && IEnumerableExt.count(prop.GetCustomAttributes <InspectableAttribute>()) == 0)
                {
                    continue;
                }

                var inspector = TypeInspectorUtils.getInspectorForType(prop.PropertyType, _target, prop);
                if (inspector != null)
                {
                    inspector.setStructTarget(_target, this, prop);
                    inspector.initialize();
                    _inspectors.Add(inspector);
                }
            }
        }
Пример #5
0
        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);
                }
            }
        }
        public override void Initialize()
        {
            base.Initialize();

            Effect effect = GetValue <Effect>();

            _name += $" ({effect.GetType().Name})";

            List <AbstractTypeInspector> inspectors = TypeInspectorUtils.GetInspectableProperties(effect);

            foreach (AbstractTypeInspector 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();

            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);
                }
            }
        }