public VolumeEffectComponent(Component c, VolumeEffectComponentFlags compFlags)
     : this(compFlags.componentName)
 {
     foreach (VolumeEffectFieldFlags current in compFlags.componentFields)
     {
         if (current.blendFlag)
         {
             FieldInfo field = c.GetType().GetField(current.fieldName);
             VolumeEffectField volumeEffectField = (!VolumeEffectField.IsValidType(field.FieldType.FullName)) ? null : new VolumeEffectField(field, c);
             if (volumeEffectField != null)
             {
                 this.fields.Add(volumeEffectField);
             }
         }
     }
 }
 public VolumeEffectComponent AddComponent( Component c, VolumeEffectComponentFlags compFlags )
 {
     if ( compFlags == null )
     {
     VolumeEffectComponent created = new VolumeEffectComponent( c.GetType() + "" );
     components.Add( created );
     return created;
     }
     else
     {
     VolumeEffectComponent component;
     if ( ( component = components.Find( s => s.componentName == c.GetType() + "" ) ) != null )
     {
         component.UpdateComponent( c, compFlags );
         return component;
     }
     else
     {
         VolumeEffectComponent created = new VolumeEffectComponent( c, compFlags );
         components.Add( created );
         return created;
     }
     }
 }
        public void UpdateComponent( Component c, VolumeEffectComponentFlags compFlags )
        {
            foreach ( VolumeEffectFieldFlags fieldFlags in compFlags.componentFields )
            {
            if ( !fieldFlags.blendFlag )
                continue;

            if ( !fields.Exists( s => s.fieldName == fieldFlags.fieldName ) )
            {
            #if !UNITY_EDITOR && UNITY_METRO
                FieldInfo pi=c.GetType().GetRuntimeField(fieldFlags.fieldName);
            #else
                FieldInfo pi = c.GetType().GetField( fieldFlags.fieldName );
            #endif
                VolumeEffectField field = VolumeEffectField.IsValidType( pi.FieldType.FullName ) ? new VolumeEffectField( pi, c ) : null;
                if ( field != null )
                    fields.Add( field );
            }
            }
        }
Exemple #4
0
 public VolumeEffectComponent AddComponent(Component c, VolumeEffectComponentFlags compFlags)
 {
     if (compFlags == null)
     {
         VolumeEffectComponent volumeEffectComponent = new VolumeEffectComponent(c.GetType() + string.Empty);
         this.components.Add(volumeEffectComponent);
         return volumeEffectComponent;
     }
     VolumeEffectComponent volumeEffectComponent2;
     if ((volumeEffectComponent2 = this.components.Find((VolumeEffectComponent s) => s.componentName == c.GetType() + string.Empty)) != null)
     {
         volumeEffectComponent2.UpdateComponent(c, compFlags);
         return volumeEffectComponent2;
     }
     VolumeEffectComponent volumeEffectComponent3 = new VolumeEffectComponent(c, compFlags);
     this.components.Add(volumeEffectComponent3);
     return volumeEffectComponent3;
 }
 public void UpdateComponent(Component c, VolumeEffectComponentFlags compFlags)
 {
     foreach (VolumeEffectFieldFlags fieldFlags in compFlags.componentFields)
     {
         if (fieldFlags.blendFlag)
         {
             if (!this.fields.Exists((VolumeEffectField s) => s.fieldName == fieldFlags.fieldName))
             {
                 FieldInfo field = c.GetType().GetField(fieldFlags.fieldName);
                 VolumeEffectField volumeEffectField = (!VolumeEffectField.IsValidType(field.FieldType.FullName)) ? null : new VolumeEffectField(field, c);
                 if (volumeEffectField != null)
                 {
                     this.fields.Add(volumeEffectField);
                 }
             }
         }
     }
 }