Inheritance: System.Attribute
Ejemplo n.º 1
0
        /// <summary>
        /// Get all NextGenSprites properties and assign them to the array.
        /// </summary>
        /// <param name="firstMat">first material</param>
        /// <param name="secondMat">second material</param>
        private void BuildProperties(Material firstMat, Material secondMat)
        {
            var FloatsList = new List <FloatPropertyRange>();
            var ColorsList = new List <ColorPropertyRange>();

            //Float Properties
            //We cast the Enum to an Array to use it lenghts for iterating through it
            var floatNames = Enum.GetNames(typeof(ShaderFloat));

            foreach (var item in floatNames)
            {
                //Parse the string back to the Enum
                var enumParsed = (ShaderFloat)Enum.Parse(typeof(ShaderFloat), item);

                if (firstMat.HasProperty(enumParsed.GetString()))
                {
                    var target = new FloatPropertyRange();

                    target.Property    = enumParsed;
                    target.ValueMain   = firstMat.GetFloat(enumParsed.GetString());
                    target.ValueSecond = secondMat.GetFloat(enumParsed.GetString());
                    FloatsList.Add(target);
                }
            }

            //Tints
            //We cast the Enum to an Array to use it lenghts for iterating through it
            var colorNames = Enum.GetNames(typeof(ShaderColor));

            foreach (var item in colorNames)
            {
                //Parse the string back to the Enum
                var enumParsed = (ShaderColor)Enum.Parse(typeof(ShaderColor), item);

                if (firstMat.HasProperty(enumParsed.GetString()))
                {
                    var target = new ColorPropertyRange();

                    target.Property    = enumParsed;
                    target.ValueMain   = firstMat.GetColor(enumParsed.GetString());
                    target.ValueSecond = secondMat.GetColor(enumParsed.GetString());
                    ColorsList.Add(target);
                }
            }

            FloatPropertyValues = FloatsList.ToArray();
            ColorPropertyValues = ColorsList.ToArray();
        }
Ejemplo n.º 2
0
        public FilterProperty(PropertyInfo info, AGATFilter filterInstance)
        {
            _info = info;

            object[] attributes = info.GetCustomAttributes(typeof(FloatPropertyRange), true);

            if (attributes.Length == 0)
            {
                attributes = info.GetCustomAttributes(typeof(ToggleGroupProperty), true);
                if (attributes.Length == 1)
                {
                    _isGroupToggle = true;
                }
            }
            else
            {
                _range = ( FloatPropertyRange )attributes[0];
            }


            object val = info.GetValue(filterInstance, null);

            if (val is float)
            {
                _currentValue = ( float )val;
                _labelString  = _info.Name + ": " + _currentValue.ToString("0.00");
            }
            else if (val is double)
            {
                _currentValue = ( float )(( double )val);
                _labelString  = _info.Name + ": " + _currentValue.ToString("0.00");
            }
            else if (val is bool)
            {
                GroupToggleState = ( bool )val;
                _labelString     = _info.Name;
            }

            _filter = filterInstance;
        }
Ejemplo n.º 3
0
        public FilterProperty( PropertyInfo info, AGATFilter filterInstance )
        {
            _info = info;

            object[] attributes = info.GetCustomAttributes( typeof( FloatPropertyRange ), true );

            if( attributes.Length == 0 )
            {
                attributes = info.GetCustomAttributes( typeof( ToggleGroupProperty ), true );
                if( attributes.Length == 1 )
                {
                    _isGroupToggle = true;
                }
            }
            else
            {
                _range = ( FloatPropertyRange )attributes[ 0 ];
            }

            object val = info.GetValue( filterInstance, null );

            if( val is float )
            {
                _currentValue = ( float )val;
                _labelString = _info.Name + ": " + _currentValue.ToString("0.00");
            }
            else if( val is double )
            {
                _currentValue = ( float )( ( double )val );
                _labelString = _info.Name + ": " + _currentValue.ToString("0.00");
            }
            else if( val is bool )
            {
                GroupToggleState = ( bool )val;
                _labelString = _info.Name;
            }

            _filter = filterInstance;
        }