public VolumeEffect AddJustColorEffect(AmplifyColorBase colorEffect)
        {
            VolumeEffect volumeEffect = new VolumeEffect(colorEffect);

            this.volumes.Add(volumeEffect);
            return(volumeEffect);
        }
Esempio n. 2
0
        public VolumeEffect AddJustColorEffect(AmplifyColorEffect colorEffect)
        {
            VolumeEffect created = new VolumeEffect(colorEffect);

            volumes.Add(created);
            return(created);
        }
Esempio n. 3
0
        public void BlendValues(AmplifyColorEffect targetColor, VolumeEffect other, float blendAmount)
        {
            VolumeEffectFlags effectFlags = targetColor.EffectFlags;
            GameObject        go          = targetColor.gameObject;

            for (int comp = 0; comp < effectFlags.components.Count; comp++)
            {
                VolumeEffectComponentFlags compFlags = effectFlags.components[comp];
                if (!compFlags.blendFlag)
                {
                    continue;
                }

                Component             c               = go.GetComponent(compFlags.componentName);
                VolumeEffectComponent effectComp      = FindEffectComponent(compFlags.componentName);
                VolumeEffectComponent effectCompOther = other.FindEffectComponent(compFlags.componentName);
                if (c == null || effectComp == null || effectCompOther == null)
                {
                    continue;
                }

                for (int i = 0; i < compFlags.componentFields.Count; i++)
                {
                    VolumeEffectFieldFlags fieldFlags = compFlags.componentFields[i];
                    if (!fieldFlags.blendFlag)
                    {
                        continue;
                    }

#if !UNITY_EDITOR && UNITY_METRO
                    FieldInfo fi = c.GetType().GetRuntimeField(fieldFlags.fieldName);
#else
                    FieldInfo fi = c.GetType().GetField(fieldFlags.fieldName);
#endif
                    VolumeEffectField effectField      = effectComp.FindEffectField(fieldFlags.fieldName);
                    VolumeEffectField effectFieldOther = effectCompOther.FindEffectField(fieldFlags.fieldName);

                    if (fi == null || effectField == null || effectFieldOther == null)
                    {
                        continue;
                    }

                    switch (fi.FieldType.FullName)
                    {
                    case "System.Single": fi.SetValue(c, Mathf.Lerp(effectField.valueSingle, effectFieldOther.valueSingle, blendAmount)); break;

                    case "System.Boolean": fi.SetValue(c, effectFieldOther.valueBoolean); break;

                    case "UnityEngine.Vector2": fi.SetValue(c, Vector2.Lerp(effectField.valueVector2, effectFieldOther.valueVector2, blendAmount)); break;

                    case "UnityEngine.Vector3": fi.SetValue(c, Vector3.Lerp(effectField.valueVector3, effectFieldOther.valueVector3, blendAmount)); break;

                    case "UnityEngine.Vector4": fi.SetValue(c, Vector4.Lerp(effectField.valueVector4, effectFieldOther.valueVector4, blendAmount)); break;

                    case "UnityEngine.Color": fi.SetValue(c, Color.Lerp(effectField.valueColor, effectFieldOther.valueColor, blendAmount)); break;
                    }
                }
            }
        }
Esempio n. 4
0
        public static VolumeEffect BlendValuesToVolumeEffect(VolumeEffectFlags flags, VolumeEffect volume1, VolumeEffect volume2, float blend)
        {
            VolumeEffect volumeEffect = new VolumeEffect(volume1.gameObject);

            foreach (VolumeEffectComponentFlags compFlags in flags.components)
            {
                if (compFlags.blendFlag)
                {
                    VolumeEffectComponent volumeEffectComponent  = volume1.components.Find((VolumeEffectComponent s) => s.componentName == compFlags.componentName);
                    VolumeEffectComponent volumeEffectComponent2 = volume2.components.Find((VolumeEffectComponent s) => s.componentName == compFlags.componentName);
                    if (volumeEffectComponent != null && volumeEffectComponent2 != null)
                    {
                        VolumeEffectComponent volumeEffectComponent3 = new VolumeEffectComponent(volumeEffectComponent.componentName);
                        foreach (VolumeEffectFieldFlags fieldFlags in compFlags.componentFields)
                        {
                            if (fieldFlags.blendFlag)
                            {
                                VolumeEffectField volumeEffectField  = volumeEffectComponent.fields.Find((VolumeEffectField s) => s.fieldName == fieldFlags.fieldName);
                                VolumeEffectField volumeEffectField2 = volumeEffectComponent2.fields.Find((VolumeEffectField s) => s.fieldName == fieldFlags.fieldName);
                                if (volumeEffectField != null && volumeEffectField2 != null)
                                {
                                    VolumeEffectField volumeEffectField3 = new VolumeEffectField(volumeEffectField.fieldName, volumeEffectField.fieldType);
                                    string            fieldType          = volumeEffectField3.fieldType;
                                    switch (fieldType)
                                    {
                                    case "System.Single":
                                        volumeEffectField3.valueSingle = Mathf.Lerp(volumeEffectField.valueSingle, volumeEffectField2.valueSingle, blend);
                                        break;

                                    case "System.Boolean":
                                        volumeEffectField3.valueBoolean = volumeEffectField2.valueBoolean;
                                        break;

                                    case "UnityEngine.Vector2":
                                        volumeEffectField3.valueVector2 = Vector2.Lerp(volumeEffectField.valueVector2, volumeEffectField2.valueVector2, blend);
                                        break;

                                    case "UnityEngine.Vector3":
                                        volumeEffectField3.valueVector3 = Vector3.Lerp(volumeEffectField.valueVector3, volumeEffectField2.valueVector3, blend);
                                        break;

                                    case "UnityEngine.Vector4":
                                        volumeEffectField3.valueVector4 = Vector4.Lerp(volumeEffectField.valueVector4, volumeEffectField2.valueVector4, blend);
                                        break;

                                    case "UnityEngine.Color":
                                        volumeEffectField3.valueColor = Color.Lerp(volumeEffectField.valueColor, volumeEffectField2.valueColor, blend);
                                        break;
                                    }
                                    volumeEffectComponent3.fields.Add(volumeEffectField3);
                                }
                            }
                        }
                        volumeEffect.components.Add(volumeEffectComponent3);
                    }
                }
            }
            return(volumeEffect);
        }
Esempio n. 5
0
        public void BlendValues(AmplifyColorBase targetColor, VolumeEffect other, float blendAmount)
        {
            VolumeEffectFlags effectFlags = targetColor.EffectFlags;
            GameObject        gameObject  = targetColor.gameObject;

            foreach (VolumeEffectComponentFlags compFlags in effectFlags.components)
            {
                if (compFlags.blendFlag)
                {
                    Component             component              = gameObject.GetComponent(compFlags.componentName);
                    VolumeEffectComponent volumeEffectComponent  = this.components.Find((VolumeEffectComponent s) => s.componentName == compFlags.componentName);
                    VolumeEffectComponent volumeEffectComponent2 = other.components.Find((VolumeEffectComponent s) => s.componentName == compFlags.componentName);
                    if (!(component == null) && volumeEffectComponent != null && volumeEffectComponent2 != null)
                    {
                        foreach (VolumeEffectFieldFlags fieldFlags in compFlags.componentFields)
                        {
                            if (fieldFlags.blendFlag)
                            {
                                FieldInfo         field              = component.GetType().GetField(fieldFlags.fieldName);
                                VolumeEffectField volumeEffectField  = volumeEffectComponent.fields.Find((VolumeEffectField s) => s.fieldName == fieldFlags.fieldName);
                                VolumeEffectField volumeEffectField2 = volumeEffectComponent2.fields.Find((VolumeEffectField s) => s.fieldName == fieldFlags.fieldName);
                                if (field != null && volumeEffectField != null && volumeEffectField2 != null)
                                {
                                    string fullName = field.FieldType.FullName;
                                    switch (fullName)
                                    {
                                    case "System.Single":
                                        field.SetValue(component, Mathf.Lerp(volumeEffectField.valueSingle, volumeEffectField2.valueSingle, blendAmount));
                                        break;

                                    case "System.Boolean":
                                        field.SetValue(component, volumeEffectField2.valueBoolean);
                                        break;

                                    case "UnityEngine.Vector2":
                                        field.SetValue(component, Vector2.Lerp(volumeEffectField.valueVector2, volumeEffectField2.valueVector2, blendAmount));
                                        break;

                                    case "UnityEngine.Vector3":
                                        field.SetValue(component, Vector3.Lerp(volumeEffectField.valueVector3, volumeEffectField2.valueVector3, blendAmount));
                                        break;

                                    case "UnityEngine.Vector4":
                                        field.SetValue(component, Vector4.Lerp(volumeEffectField.valueVector4, volumeEffectField2.valueVector4, blendAmount));
                                        break;

                                    case "UnityEngine.Color":
                                        field.SetValue(component, Color.Lerp(volumeEffectField.valueColor, volumeEffectField2.valueColor, blendAmount));
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 6
0
        public VolumeEffect GetVolumeEffect(AmplifyColorBase colorEffect)
        {
            VolumeEffect volumeEffect = (volumes.Find(s => s.gameObject == colorEffect));

            if (volumeEffect == null)
            {
                volumeEffect = volumes.Find(s => s.gameObject != null && s.gameObject.SharedInstanceID == colorEffect.SharedInstanceID);
            }
            return(volumeEffect);
        }
Esempio n. 7
0
        public static VolumeEffect BlendValuesToVolumeEffect(VolumeEffectFlags flags, VolumeEffect volume1, VolumeEffect volume2, float blend)
        {
            VolumeEffect resultVolume = new VolumeEffect(volume1.gameObject);

            foreach (VolumeEffectComponentFlags compFlags in flags.components)
            {
                if (!compFlags.blendFlag)
                {
                    continue;
                }

                VolumeEffectComponent ec1 = volume1.FindEffectComponent(compFlags.componentName);
                VolumeEffectComponent ec2 = volume2.FindEffectComponent(compFlags.componentName);
                if (ec1 == null || ec2 == null)
                {
                    continue;
                }

                VolumeEffectComponent resultComp = new VolumeEffectComponent(ec1.componentName);
                foreach (VolumeEffectFieldFlags fieldFlags in compFlags.componentFields)
                {
                    if (fieldFlags.blendFlag)
                    {
                        VolumeEffectField ef1 = ec1.FindEffectField(fieldFlags.fieldName);
                        VolumeEffectField ef2 = ec2.FindEffectField(fieldFlags.fieldName);
                        if (ef1 == null || ef2 == null)
                        {
                            continue;
                        }

                        VolumeEffectField resultField = new VolumeEffectField(ef1.fieldName, ef1.fieldType);

                        switch (resultField.fieldType)
                        {
                        case "System.Single": resultField.valueSingle = Mathf.Lerp(ef1.valueSingle, ef2.valueSingle, blend); break;

                        case "System.Boolean": resultField.valueBoolean = ef2.valueBoolean; break;

                        case "UnityEngine.Vector2": resultField.valueVector2 = Vector2.Lerp(ef1.valueVector2, ef2.valueVector2, blend); break;

                        case "UnityEngine.Vector3": resultField.valueVector3 = Vector3.Lerp(ef1.valueVector3, ef2.valueVector3, blend); break;

                        case "UnityEngine.Vector4": resultField.valueVector4 = Vector4.Lerp(ef1.valueVector4, ef2.valueVector4, blend); break;

                        case "UnityEngine.Color": resultField.valueColor = Color.Lerp(ef1.valueColor, ef2.valueColor, blend); break;
                        }

                        resultComp.fields.Add(resultField);
                    }
                }
                resultVolume.components.Add(resultComp);
            }
            return(resultVolume);
        }
Esempio n. 8
0
 public static VolumeEffect BlendValuesToVolumeEffect(VolumeEffectFlags flags, VolumeEffect volume1, VolumeEffect volume2, float blend)
 {
     VolumeEffect volumeEffect = new VolumeEffect(volume1.gameObject);
     foreach (VolumeEffectComponentFlags compFlags in flags.components)
     {
         if (compFlags.blendFlag)
         {
             VolumeEffectComponent volumeEffectComponent = volume1.components.Find((VolumeEffectComponent s) => s.componentName == compFlags.componentName);
             VolumeEffectComponent volumeEffectComponent2 = volume2.components.Find((VolumeEffectComponent s) => s.componentName == compFlags.componentName);
             if (volumeEffectComponent != null && volumeEffectComponent2 != null)
             {
                 VolumeEffectComponent volumeEffectComponent3 = new VolumeEffectComponent(volumeEffectComponent.componentName);
                 foreach (VolumeEffectFieldFlags fieldFlags in compFlags.componentFields)
                 {
                     if (fieldFlags.blendFlag)
                     {
                         VolumeEffectField volumeEffectField = volumeEffectComponent.fields.Find((VolumeEffectField s) => s.fieldName == fieldFlags.fieldName);
                         VolumeEffectField volumeEffectField2 = volumeEffectComponent2.fields.Find((VolumeEffectField s) => s.fieldName == fieldFlags.fieldName);
                         if (volumeEffectField != null && volumeEffectField2 != null)
                         {
                             VolumeEffectField volumeEffectField3 = new VolumeEffectField(volumeEffectField.fieldName, volumeEffectField.fieldType);
                             string fieldType = volumeEffectField3.fieldType;
                             switch (fieldType)
                             {
                             case "System.Single":
                                 volumeEffectField3.valueSingle = Mathf.Lerp(volumeEffectField.valueSingle, volumeEffectField2.valueSingle, blend);
                                 break;
                             case "System.Boolean":
                                 volumeEffectField3.valueBoolean = volumeEffectField2.valueBoolean;
                                 break;
                             case "UnityEngine.Vector2":
                                 volumeEffectField3.valueVector2 = Vector2.Lerp(volumeEffectField.valueVector2, volumeEffectField2.valueVector2, blend);
                                 break;
                             case "UnityEngine.Vector3":
                                 volumeEffectField3.valueVector3 = Vector3.Lerp(volumeEffectField.valueVector3, volumeEffectField2.valueVector3, blend);
                                 break;
                             case "UnityEngine.Vector4":
                                 volumeEffectField3.valueVector4 = Vector4.Lerp(volumeEffectField.valueVector4, volumeEffectField2.valueVector4, blend);
                                 break;
                             case "UnityEngine.Color":
                                 volumeEffectField3.valueColor = Color.Lerp(volumeEffectField.valueColor, volumeEffectField2.valueColor, blend);
                                 break;
                             }
                             volumeEffectComponent3.fields.Add(volumeEffectField3);
                         }
                     }
                 }
                 volumeEffect.components.Add(volumeEffectComponent3);
             }
         }
     }
     return volumeEffect;
 }
Esempio n. 9
0
        public void AddColorEffect(AmplifyColorBase colorEffect)
        {
            VolumeEffect volumeEffect;

            if ((volumeEffect = this.FindVolumeEffect(colorEffect)) != null)
            {
                volumeEffect.UpdateVolume();
                return;
            }
            volumeEffect = new VolumeEffect(colorEffect);
            this.volumes.Add(volumeEffect);
            volumeEffect.UpdateVolume();
        }
Esempio n. 10
0
 public void AddColorEffect(AmplifyColorBase colorEffect)
 {
     VolumeEffect volumeEffect;
     if ((volumeEffect = this.volumes.Find((VolumeEffect s) => s.gameObject == colorEffect)) != null)
     {
         volumeEffect.UpdateVolume();
     }
     else
     {
         volumeEffect = new VolumeEffect(colorEffect);
         this.volumes.Add(volumeEffect);
         volumeEffect.UpdateVolume();
     }
 }
Esempio n. 11
0
 public static void UpdateCamFlags(AmplifyColorBase[] effects, AmplifyColorVolumeBase[] volumes)
 {
     foreach (AmplifyColorBase amplifyColorBase in effects)
     {
         amplifyColorBase.EffectFlags = new VolumeEffectFlags();
         for (int j = 0; j < volumes.Length; j++)
         {
             VolumeEffect volumeEffect = volumes[j].EffectContainer.FindVolumeEffect(amplifyColorBase);
             if (volumeEffect != null)
             {
                 amplifyColorBase.EffectFlags.UpdateFlags(volumeEffect);
             }
         }
     }
 }
 public static void UpdateCamFlags(AmplifyColorBase[] effects, AmplifyColorVolumeBase[] volumes)
 {
     foreach (AmplifyColorBase effect in effects)
     {
         effect.EffectFlags = new VolumeEffectFlags();
         foreach (AmplifyColorVolumeBase volume in volumes)
         {
             VolumeEffect effectVolume = volume.EffectContainer.GetVolumeEffect(effect);
             if (effectVolume != null)
             {
                 effect.EffectFlags.UpdateFlags(effectVolume);
             }
         }
     }
 }
 public void UpdateFlags(VolumeEffect effectVol)
 {
     foreach (VolumeEffectComponent comp in effectVol.components)
     {
         VolumeEffectComponentFlags compFlags = null;
         if ((compFlags = components.Find(s => s.componentName == comp.componentName)) == null)
         {
             components.Add(new VolumeEffectComponentFlags(comp));
         }
         else
         {
             compFlags.UpdateComponentFlags(comp);
         }
     }
 }
Esempio n. 14
0
 public void UpdateFlags(VolumeEffect effectVol)
 {
     foreach (VolumeEffectComponent comp in effectVol.components)
     {
         VolumeEffectComponentFlags volumeEffectComponentFlags;
         if ((volumeEffectComponentFlags = this.components.Find((VolumeEffectComponentFlags s) => s.componentName == comp.componentName)) == null)
         {
             this.components.Add(new VolumeEffectComponentFlags(comp));
         }
         else
         {
             volumeEffectComponentFlags.UpdateComponentFlags(comp);
         }
     }
 }
        public void AddColorEffect(AmplifyColorBase colorEffect)
        {
            VolumeEffect volume;

            if ((volume = volumes.Find(s => s.gameObject == colorEffect)) != null)
            {
                volume.UpdateVolume();
            }
            else
            {
                volume = new VolumeEffect(colorEffect);
                volumes.Add(volume);
                volume.UpdateVolume();
            }
        }
Esempio n. 16
0
        public void AddColorEffect(AmplifyColorEffect colorEffect)
        {
            VolumeEffect volume;

            if ((volume = FindVolumeEffect(colorEffect)) != null)
            {
                volume.UpdateVolume();
            }
            else
            {
                volume = new VolumeEffect(colorEffect);
                volumes.Add(volume);
                volume.UpdateVolume();
            }
        }
Esempio n. 17
0
        public void AddColorEffect(AmplifyColorBase colorEffect)
        {
            VolumeEffect volumeEffect;

            if ((volumeEffect = this.volumes.Find((VolumeEffect s) => s.gameObject == colorEffect)) != null)
            {
                volumeEffect.UpdateVolume();
            }
            else
            {
                volumeEffect = new VolumeEffect(colorEffect);
                this.volumes.Add(volumeEffect);
                volumeEffect.UpdateVolume();
            }
        }
Esempio n. 18
0
        public VolumeEffect GenerateEffectData(AmplifyColorBase go)
        {
            VolumeEffect volumeEffect = new VolumeEffect(go);

            foreach (VolumeEffectComponentFlags volumeEffectComponentFlags in this.components)
            {
                if (volumeEffectComponentFlags.blendFlag)
                {
                    Component component = go.GetComponent(volumeEffectComponentFlags.componentName);
                    if (component != null)
                    {
                        volumeEffect.AddComponent(component, volumeEffectComponentFlags);
                    }
                }
            }
            return(volumeEffect);
        }
Esempio n. 19
0
 public static void UpdateCamFlags(AmplifyColorBase[] effects, AmplifyColorVolumeBase[] volumes)
 {
     for (int i = 0; i < effects.Length; i++)
     {
         AmplifyColorBase amplifyColorBase = effects[i];
         amplifyColorBase.EffectFlags = new VolumeEffectFlags();
         for (int j = 0; j < volumes.Length; j++)
         {
             AmplifyColorVolumeBase amplifyColorVolumeBase = volumes[j];
             VolumeEffect           volumeEffect           = amplifyColorVolumeBase.EffectContainer.GetVolumeEffect(amplifyColorBase);
             if (volumeEffect != null)
             {
                 amplifyColorBase.EffectFlags.UpdateFlags(volumeEffect);
             }
         }
     }
 }
Esempio n. 20
0
    private void Start()
    {
        if (silentError)
        {
            return;
        }

        CheckCamera();

        worldLUT = LutTexture;

        worldVolumeEffects = EffectFlags.GenerateEffectData(this);
        blendVolumeEffects = currentVolumeEffects = worldVolumeEffects;

        worldExposure = Exposure;
        blendExposure = currentExposure = worldExposure;
    }
        public VolumeEffect GenerateEffectData(AmplifyColorBase go)
        {
            VolumeEffect result = new VolumeEffect(go);

            foreach (VolumeEffectComponentFlags compFlags in components)
            {
                if (!compFlags.blendFlag)
                {
                    continue;
                }

                Component c = go.GetComponent(compFlags.componentName);
                if (c != null)
                {
                    result.AddComponent(c, compFlags);
                }
            }
            return(result);
        }
Esempio n. 22
0
 public void UpdateFlags(VolumeEffect effectVol)
 {
     using (List <VolumeEffectComponent> .Enumerator enumerator = effectVol.components.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             VolumeEffectComponent      comp = enumerator.Current;
             VolumeEffectComponentFlags volumeEffectComponentFlags;
             if ((volumeEffectComponentFlags = this.components.Find((VolumeEffectComponentFlags s) => s.componentName == comp.componentName)) == null)
             {
                 this.components.Add(new VolumeEffectComponentFlags(comp));
             }
             else
             {
                 volumeEffectComponentFlags.UpdateComponentFlags(comp);
             }
         }
     }
 }
Esempio n. 23
0
        public static VolumeEffect BlendValuesToVolumeEffect( VolumeEffectFlags flags, VolumeEffect volume1, VolumeEffect volume2, float blend )
        {
            VolumeEffect resultVolume = new VolumeEffect( volume1.gameObject );
            foreach ( VolumeEffectComponentFlags compFlags in flags.components )
            {
            if ( !compFlags.blendFlag )
                continue;

            VolumeEffectComponent ec1 = volume1.components.Find( s => s.componentName == compFlags.componentName );
            VolumeEffectComponent ec2 = volume2.components.Find( s => s.componentName == compFlags.componentName );
            if ( ec1 == null || ec2 == null )
                continue;

            VolumeEffectComponent resultComp = new VolumeEffectComponent( ec1.componentName );
            foreach ( VolumeEffectFieldFlags fieldFlags in compFlags.componentFields )
            {
                if ( fieldFlags.blendFlag )
                {
                    VolumeEffectField ef1 = ec1.fields.Find( s => s.fieldName == fieldFlags.fieldName );
                    VolumeEffectField ef2 = ec2.fields.Find( s => s.fieldName == fieldFlags.fieldName );
                    if ( ef1 == null || ef2 == null )
                        continue;

                    VolumeEffectField resultField = new VolumeEffectField( ef1.fieldName, ef1.fieldType );

                    switch ( resultField.fieldType )
                    {
                        case "System.Single": resultField.valueSingle = Mathf.Lerp( ef1.valueSingle, ef2.valueSingle, blend ); break;
                        case "System.Boolean": resultField.valueBoolean = ef2.valueBoolean; break;
                        case "UnityEngine.Vector2": resultField.valueVector2 = Vector2.Lerp( ef1.valueVector2, ef2.valueVector2, blend ); break;
                        case "UnityEngine.Vector3": resultField.valueVector3 = Vector3.Lerp( ef1.valueVector3, ef2.valueVector3, blend ); break;
                        case "UnityEngine.Vector4": resultField.valueVector4 = Vector4.Lerp( ef1.valueVector4, ef2.valueVector4, blend ); break;
                        case "UnityEngine.Color": resultField.valueColor = Color.Lerp( ef1.valueColor, ef2.valueColor, blend ); break;
                    }

                    resultComp.fields.Add( resultField );
                }
            }
            resultVolume.components.Add( resultComp );
            }
            return resultVolume;
        }
Esempio n. 24
0
 public VolumeEffect AddJustColorEffect( AmplifyColorBase colorEffect )
 {
     VolumeEffect created = new VolumeEffect( colorEffect );
     volumes.Add( created );
     return created;
 }
Esempio n. 25
0
	void Update()
	{
		if ( volumesBlending )
		{
			volumesBlendAmount = ( volumesBlendingTime - volumesBlendingTimeCountdown ) / volumesBlendingTime;
			volumesBlendingTimeCountdown -= Time.smoothDeltaTime;

			if ( volumesBlendAmount >= 1.0f )
			{
				LutTexture = volumesLutBlendTexture;
				volumesBlendAmount = 0.0f;
				volumesBlending = false;
				volumesLutBlendTexture = null;

				effectVolumesBlendAdjust = 0.0f;
				currentVolumeEffects = blendVolumeEffects;
				currentVolumeEffects.SetValues( this );

				if ( blendingFromMidBlend && midBlendLUT != null )
					midBlendLUT.DiscardContents();

				blendingFromMidBlend = false;
			}
		}
		else
			volumesBlendAmount = Mathf.Clamp01( volumesBlendAmount );

		if ( blending )
		{
			BlendAmount = ( blendingTime - blendingTimeCountdown ) / blendingTime;
			blendingTimeCountdown -= Time.smoothDeltaTime;

			if ( BlendAmount >= 1.0f )
			{
				LutTexture = LutBlendTexture;
				BlendAmount = 0.0f;
				blending = false;
				LutBlendTexture = null;

				if ( onFinishBlend != null )
					onFinishBlend();
			}
		}
		else
			BlendAmount = Mathf.Clamp01( BlendAmount );
		
		if ( UseVolumes )
		{
			if ( actualTriggerProxy == null )
			{
				GameObject obj = new GameObject( name + "+ACVolumeProxy" ) { hideFlags = HideFlags.HideAndDontSave };
				actualTriggerProxy = obj.AddComponent<AmplifyColorTriggerProxy>();
				actualTriggerProxy.OwnerEffect = this;
			}

			UpdateVolumes();
		}
		else if ( actualTriggerProxy != null )
		{
			DestroyImmediate( actualTriggerProxy.gameObject );
			actualTriggerProxy = null;			
		}
	}
Esempio n. 26
0
	private void Start()
	{
		worldLUT = LutTexture;
		worldVolumeEffects = EffectFlags.GenerateEffectData( this );
		blendVolumeEffects = currentVolumeEffects = worldVolumeEffects;
	}
Esempio n. 27
0
    void Update()
    {
        if (silentError)
        {
            return;
        }

        CheckCamera();

        bool volumesBlendFinished = false;

        if (volumesBlending)
        {
            volumesBlendAmount            = (volumesBlendingTime - volumesBlendingTimeCountdown) / volumesBlendingTime;
            volumesBlendingTimeCountdown -= Time.smoothDeltaTime;

            if (volumesBlendAmount >= 1.0f)
            {
                volumesBlendAmount   = 1;
                volumesBlendFinished = true;
            }
        }
        else
        {
            volumesBlendAmount = Mathf.Clamp01(volumesBlendAmount);
        }

        if (blending)
        {
            BlendAmount            = (blendingTime - blendingTimeCountdown) / blendingTime;
            blendingTimeCountdown -= Time.smoothDeltaTime;

            if (BlendAmount >= 1.0f)
            {
                LutTexture      = LutBlendTexture;
                BlendAmount     = 0.0f;
                blending        = false;
                LutBlendTexture = null;

                if (onFinishBlend != null)
                {
                    onFinishBlend();
                }
            }
        }
        else
        {
            BlendAmount = Mathf.Clamp01(BlendAmount);
        }

        if (UseVolumes)
        {
            if (actualTriggerProxy == null)
            {
                GameObject obj = new GameObject(name + "+ACVolumeProxy")
                {
                    hideFlags = HideFlags.HideAndDontSave
                };
                if (TriggerVolumeProxy != null && TriggerVolumeProxy.GetComponent <Collider2D>() != null)
                {
                    actualTriggerProxy = obj.AddComponent <AmplifyColorTriggerProxy2D>();
                }
                else
                {
                    actualTriggerProxy = obj.AddComponent <AmplifyColorTriggerProxy>();
                }
                actualTriggerProxy.OwnerEffect = this;
            }

            UpdateVolumes();
        }
        else if (actualTriggerProxy != null)
        {
            DestroyImmediate(actualTriggerProxy.gameObject);
            actualTriggerProxy = null;
        }

        if (volumesBlendFinished)
        {
            LutTexture             = volumesLutBlendTexture;
            volumesBlendAmount     = 0.0f;
            volumesBlending        = false;
            volumesLutBlendTexture = null;

            effectVolumesBlendAdjust = 0.0f;
            currentVolumeEffects     = blendVolumeEffects;
            currentVolumeEffects.SetValues(this);
            currentExposure = blendExposure;

            if (blendingFromMidBlend && midBlendLUT != null)
            {
                midBlendLUT.DiscardContents();
            }

            blendingFromMidBlend = false;
        }
    }
Esempio n. 28
0
    private void UpdateVolumes()
    {
        if (volumesBlending)
        {
            currentVolumeEffects.BlendValues(this, blendVolumeEffects, effectVolumesBlendAdjusted);
        }

        if (volumesBlending)
        {
            Exposure = Mathf.Lerp(currentExposure, blendExposure, effectVolumesBlendAdjusted);
        }

        Transform reference = (TriggerVolumeProxy == null) ? transform : TriggerVolumeProxy;

        if (actualTriggerProxy.transform.parent != reference)
        {
            actualTriggerProxy.Reference        = reference;
            actualTriggerProxy.gameObject.layer = reference.gameObject.layer;
        }

        AmplifyColorVolumeBase foundVolume = null;
        int maxPriority = int.MinValue;

        // Find volume with higher priority
        for (int i = 0; i < enteredVolumes.Count; i++)
        {
            AmplifyColorVolumeBase vol = enteredVolumes[i];
            if (vol.Priority > maxPriority)
            {
                foundVolume = vol;
                maxPriority = vol.Priority;
            }
        }

        // Trigger blend on volume transition
        if (foundVolume != currentVolumeLut)
        {
            currentVolumeLut = foundVolume;
            Texture blendTex  = (foundVolume == null ? worldLUT : foundVolume.LutTexture);
            float   blendTime = (foundVolume == null ? ExitVolumeBlendTime : foundVolume.EnterBlendTime);

            if (volumesBlending && !blendingFromMidBlend && blendTex == LutTexture)
            {
                // Going back to previous volume optimization
                LutTexture                   = volumesLutBlendTexture;
                volumesLutBlendTexture       = blendTex;
                volumesBlendingTimeCountdown = blendTime * ((volumesBlendingTime - volumesBlendingTimeCountdown) / volumesBlendingTime);
                volumesBlendingTime          = blendTime;
                currentVolumeEffects         = AmplifyColor.VolumeEffect.BlendValuesToVolumeEffect(EffectFlags, currentVolumeEffects, blendVolumeEffects, effectVolumesBlendAdjusted);
                currentExposure              = Mathf.Lerp(currentExposure, blendExposure, effectVolumesBlendAdjusted);
                effectVolumesBlendAdjust     = 1 - volumesBlendAmount;
                volumesBlendAmount           = 1 - volumesBlendAmount;
            }
            else
            {
                if (volumesBlending)
                {
                    materialBlendCache.SetFloat("_LerpAmount", volumesBlendAmount);

                    if (blendingFromMidBlend)
                    {
                        Graphics.Blit(midBlendLUT, blendCacheLut);
                        materialBlendCache.SetTexture("_RgbTex", blendCacheLut);
                    }
                    else
                    {
                        materialBlendCache.SetTexture("_RgbTex", LutTexture);
                    }

                    materialBlendCache.SetTexture("_LerpRgbTex", (volumesLutBlendTexture != null) ? volumesLutBlendTexture : defaultLut);

                    Graphics.Blit(midBlendLUT, midBlendLUT, materialBlendCache);

                    blendCacheLut.DiscardContents();
                                #if !UNITY_5_6_OR_NEWER
                    midBlendLUT.MarkRestoreExpected();
                                #endif

                    currentVolumeEffects     = AmplifyColor.VolumeEffect.BlendValuesToVolumeEffect(EffectFlags, currentVolumeEffects, blendVolumeEffects, effectVolumesBlendAdjusted);
                    currentExposure          = Mathf.Lerp(currentExposure, blendExposure, effectVolumesBlendAdjusted);
                    effectVolumesBlendAdjust = 0.0f;
                    blendingFromMidBlend     = true;
                }
                VolumesBlendTo(blendTex, blendTime);
            }

            blendVolumeEffects = (foundVolume == null) ? worldVolumeEffects : foundVolume.EffectContainer.FindVolumeEffect(this);
            blendExposure      = (foundVolume == null) ? worldExposure : foundVolume.Exposure;
            if (blendVolumeEffects == null)
            {
                blendVolumeEffects = worldVolumeEffects;
            }
        }
    }
Esempio n. 29
0
 private void Start()
 {
     this.worldLUT = this.LutTexture;
     this.worldVolumeEffects = this.EffectFlags.GenerateEffectData(this);
     this.blendVolumeEffects = (this.currentVolumeEffects = this.worldVolumeEffects);
 }
Esempio n. 30
0
	private void UpdateVolumes()
	{
		if ( volumesBlending )
			currentVolumeEffects.BlendValues( this, blendVolumeEffects, effectVolumesBlendAdjusted );

		Transform reference = ( TriggerVolumeProxy == null ) ? transform : TriggerVolumeProxy;

		if ( actualTriggerProxy.transform.parent != reference )
		{
			actualTriggerProxy.Reference = reference;
			actualTriggerProxy.gameObject.layer = reference.gameObject.layer;
		}
	
		AmplifyColorVolumeBase foundVolume = null;
		int maxPriority = int.MinValue;

		// Find volume with higher priority
		foreach ( AmplifyColorVolumeBase vol in enteredVolumes )
		{
			if ( vol.Priority > maxPriority )
			{
				foundVolume = vol;
				maxPriority = vol.Priority;
			}
		}			

		// Trigger blend on volume transition
		if ( foundVolume != currentVolumeLut )
		{
			currentVolumeLut = foundVolume;
			Texture2D blendTex = ( foundVolume == null ? worldLUT : foundVolume.LutTexture );
			float blendTime = ( foundVolume == null ? ExitVolumeBlendTime : foundVolume.EnterBlendTime );

			if ( volumesBlending && !blendingFromMidBlend && blendTex == LutTexture )
			{
				// Going back to previous volume optimization
				LutTexture = volumesLutBlendTexture;
				volumesLutBlendTexture = blendTex;
				volumesBlendingTimeCountdown = blendTime * ( ( volumesBlendingTime - volumesBlendingTimeCountdown ) / volumesBlendingTime );
				volumesBlendingTime = blendTime;
				currentVolumeEffects = VolumeEffect.BlendValuesToVolumeEffect( EffectFlags, currentVolumeEffects, blendVolumeEffects, effectVolumesBlendAdjusted );
				effectVolumesBlendAdjust = 1 - volumesBlendAmount;
				volumesBlendAmount = 1 - volumesBlendAmount;
			}
			else
			{
				if ( volumesBlending )
				{
					materialBlendCache.SetFloat( "_lerpAmount", volumesBlendAmount );

					if ( blendingFromMidBlend )
					{
						Graphics.Blit( midBlendLUT, blendCacheLut );
						materialBlendCache.SetTexture( "_RgbTex", blendCacheLut );
					}
					else
						materialBlendCache.SetTexture( "_RgbTex", LutTexture );

					materialBlendCache.SetTexture( "_LerpRgbTex", ( volumesLutBlendTexture != null ) ? volumesLutBlendTexture : normalLut );

					Graphics.Blit( midBlendLUT, midBlendLUT, materialBlendCache );

					blendCacheLut.DiscardContents();
				#if UNITY_4
					midBlendLUT.MarkRestoreExpected();
				#endif

					currentVolumeEffects = VolumeEffect.BlendValuesToVolumeEffect( EffectFlags, currentVolumeEffects, blendVolumeEffects, effectVolumesBlendAdjusted );
					effectVolumesBlendAdjust = 0.0f;
					blendingFromMidBlend = true;
				}
				VolumesBlendTo( blendTex, blendTime );
			}

			blendVolumeEffects = ( foundVolume == null ? worldVolumeEffects : foundVolume.EffectContainer.GetVolumeEffect( this ) );
			if ( blendVolumeEffects == null )
				blendVolumeEffects = worldVolumeEffects;
		}
	}
Esempio n. 31
0
 public VolumeEffect AddJustColorEffect(AmplifyColorBase colorEffect)
 {
     VolumeEffect volumeEffect = new VolumeEffect(colorEffect);
     this.volumes.Add(volumeEffect);
     return volumeEffect;
 }
Esempio n. 32
0
 public void BlendValues(AmplifyColorBase targetColor, VolumeEffect other, float blendAmount)
 {
     VolumeEffectFlags effectFlags = targetColor.EffectFlags;
     GameObject gameObject = targetColor.gameObject;
     foreach (VolumeEffectComponentFlags compFlags in effectFlags.components)
     {
         if (compFlags.blendFlag)
         {
             Component component = gameObject.GetComponent(compFlags.componentName);
             VolumeEffectComponent volumeEffectComponent = this.components.Find((VolumeEffectComponent s) => s.componentName == compFlags.componentName);
             VolumeEffectComponent volumeEffectComponent2 = other.components.Find((VolumeEffectComponent s) => s.componentName == compFlags.componentName);
             if (!(component == null) && volumeEffectComponent != null && volumeEffectComponent2 != null)
             {
                 foreach (VolumeEffectFieldFlags fieldFlags in compFlags.componentFields)
                 {
                     if (fieldFlags.blendFlag)
                     {
                         FieldInfo field = component.GetType().GetField(fieldFlags.fieldName);
                         VolumeEffectField volumeEffectField = volumeEffectComponent.fields.Find((VolumeEffectField s) => s.fieldName == fieldFlags.fieldName);
                         VolumeEffectField volumeEffectField2 = volumeEffectComponent2.fields.Find((VolumeEffectField s) => s.fieldName == fieldFlags.fieldName);
                         if (field != null && volumeEffectField != null && volumeEffectField2 != null)
                         {
                             string fullName = field.FieldType.FullName;
                             switch (fullName)
                             {
                             case "System.Single":
                                 field.SetValue(component, Mathf.Lerp(volumeEffectField.valueSingle, volumeEffectField2.valueSingle, blendAmount));
                                 break;
                             case "System.Boolean":
                                 field.SetValue(component, volumeEffectField2.valueBoolean);
                                 break;
                             case "UnityEngine.Vector2":
                                 field.SetValue(component, Vector2.Lerp(volumeEffectField.valueVector2, volumeEffectField2.valueVector2, blendAmount));
                                 break;
                             case "UnityEngine.Vector3":
                                 field.SetValue(component, Vector3.Lerp(volumeEffectField.valueVector3, volumeEffectField2.valueVector3, blendAmount));
                                 break;
                             case "UnityEngine.Vector4":
                                 field.SetValue(component, Vector4.Lerp(volumeEffectField.valueVector4, volumeEffectField2.valueVector4, blendAmount));
                                 break;
                             case "UnityEngine.Color":
                                 field.SetValue(component, Color.Lerp(volumeEffectField.valueColor, volumeEffectField2.valueColor, blendAmount));
                                 break;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
	public void UpdateFlags( VolumeEffect effectVol )
	{
		foreach ( VolumeEffectComponent comp in effectVol.components )
		{
			VolumeEffectComponentFlags compFlags = null;
			if ( ( compFlags = components.Find( s => s.componentName == comp.componentName ) ) == null )
				components.Add( new VolumeEffectComponentFlags( comp ) );
			else
				compFlags.UpdateComponentFlags( comp );
		}
	}
	public VolumeEffect GenerateEffectData( AmplifyColorBase go )
	{
		VolumeEffect result = new VolumeEffect( go );
		foreach ( VolumeEffectComponentFlags compFlags in components )
		{
			if ( !compFlags.blendFlag )
				continue;

			Component c = go.GetComponent( compFlags.componentName );
			if ( c != null )
				result.AddComponent( c, compFlags );
		}
		return result;
	}
Esempio n. 35
0
        }                                                // 0x0085FA60-0x0085FB70

        public void UpdateFlags(VolumeEffect effectVol)
        {
        }                                                          // 0x0085FB80-0x0085FDA0
Esempio n. 36
0
 private void Update()
 {
     if (this.volumesBlending)
     {
         this.volumesBlendAmount = (this.volumesBlendingTime - this.volumesBlendingTimeCountdown) / this.volumesBlendingTime;
         this.volumesBlendingTimeCountdown -= Time.smoothDeltaTime;
         if (this.volumesBlendAmount >= 1f)
         {
             this.LutTexture = this.volumesLutBlendTexture;
             this.volumesBlendAmount = 0f;
             this.volumesBlending = false;
             this.volumesLutBlendTexture = null;
             this.effectVolumesBlendAdjust = 0f;
             this.currentVolumeEffects = this.blendVolumeEffects;
             this.currentVolumeEffects.SetValues(this);
             if (this.blendingFromMidBlend && this.midBlendLUT != null)
             {
                 this.midBlendLUT.DiscardContents();
             }
             this.blendingFromMidBlend = false;
         }
     }
     else
     {
         this.volumesBlendAmount = Mathf.Clamp01(this.volumesBlendAmount);
     }
     if (this.blending)
     {
         this.BlendAmount = (this.blendingTime - this.blendingTimeCountdown) / this.blendingTime;
         this.blendingTimeCountdown -= Time.smoothDeltaTime;
         if (this.BlendAmount >= 1f)
         {
             this.LutTexture = this.LutBlendTexture;
             this.BlendAmount = 0f;
             this.blending = false;
             this.LutBlendTexture = null;
             if (this.onFinishBlend != null)
             {
                 this.onFinishBlend();
             }
         }
     }
     else
     {
         this.BlendAmount = Mathf.Clamp01(this.BlendAmount);
     }
     if (this.UseVolumes)
     {
         if (this.actualTriggerProxy == null)
         {
             GameObject gameObject = new GameObject(base.name + "+ACVolumeProxy")
             {
                 hideFlags = HideFlags.HideAndDontSave
             };
             this.actualTriggerProxy = gameObject.AddComponent<AmplifyColorTriggerProxy>();
             this.actualTriggerProxy.OwnerEffect = this;
         }
         this.UpdateVolumes();
     }
     else if (this.actualTriggerProxy != null)
     {
         UnityEngine.Object.DestroyImmediate(this.actualTriggerProxy.gameObject);
         this.actualTriggerProxy = null;
     }
 }
Esempio n. 37
0
 public void RemoveVolumeEffect(VolumeEffect volume)
 {
     volumes.Remove(volume);
 }
Esempio n. 38
0
        }                                                              // 0x0085CDD0-0x0085D470

        public void BlendValues(AmplifyColorBase targetColor, VolumeEffect other, float blendAmount)
        {
        }                                                                                   // 0x0085D470-0x0085D9D0
Esempio n. 39
0
        }                                                       // 0x0085B900-0x0085B990

        // Methods
        public static VolumeEffect BlendValuesToVolumeEffect(VolumeEffectFlags flags, VolumeEffect volume1, VolumeEffect volume2, float blend) => default; // 0x0085B990-0x0085C1A0
    void DrawVolumeEffectFields(AmplifyColorVolumeBase volume)
    {
        List <AmplifyColor.VolumeEffect> effectsToDelete = new List <AmplifyColor.VolumeEffect>();
        float removeButtonSize = 16;

        List <NewLineContainer> volumeLines = null;

        if (!(newLines.TryGetValue(volume, out volumeLines)))
        {
            volumeLines = newLines[volume] = new List <NewLineContainer>();
        }

        GUIStyle minusStyle = new GUIStyle(( GUIStyle )"OL Minus");
        GUIStyle plusStyle  = new GUIStyle(( GUIStyle )"OL Plus");

        minusStyle.margin.top = 2;
        plusStyle.margin.top  = 2;

        #region CurrentEffectFields
        int fieldPosition = 0;
        foreach (AmplifyColor.VolumeEffect effectVol in volume.EffectContainer.volumes)
        {
            if (effectVol.gameObject == null)
            {
                continue;
            }

            AmplifyColorBase effect = effectVol.gameObject;
            List <AmplifyColor.VolumeEffectComponent> compsToDelete = new List <AmplifyColor.VolumeEffectComponent>();

            foreach (AmplifyColor.VolumeEffectComponent comp in effectVol.components)
            {
                Component c = effect.GetComponent(comp.componentName);
                if (c == null)
                {
                    continue;
                }

                List <AmplifyColor.VolumeEffectField> fieldsToDelete = new List <AmplifyColor.VolumeEffectField>();
                List <KeyValuePair <string, int> >    fieldsToAdd    = new List <KeyValuePair <string, int> >();

                foreach (AmplifyColor.VolumeEffectField field in comp.fields)
                {
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Label("", GUILayout.MinWidth(minIndentWidth), GUILayout.MaxWidth(maxIndentWidth));
                    GUILayout.Space(0);

                    if (GUILayout.Button("", minusStyle, GUILayout.MinWidth(18), GUILayout.MaxWidth(18), GUILayout.Height(20)))
                    {
                        fieldsToDelete.Add(field);
                    }

                    Camera           selectedCamera = EditorGUILayout.ObjectField(effect.GetComponent <Camera>(), typeof(Camera), true, GUILayout.MinWidth(minColumnWidth * 1.5f), GUILayout.MaxWidth(maxColumnWidth * 1.5f)) as Camera;
                    AmplifyColorBase selectedEffect = (selectedCamera != null) ? selectedCamera.GetComponent <AmplifyColorBase>() : null;
                    if (selectedEffect != effect)
                    {
                        fieldsToDelete.Add(field);
                        dirtyVolumeFlags = true;
                        volumeLines.Add(new NewLineContainer(selectedEffect));
                    }

                    Component[]   compArray      = AmplifyColor.VolumeEffect.ListAcceptableComponents(effectVol.gameObject);
                    List <string> compFlagsArray = compArray.Select(s => s.GetType().Name).ToList();
                    compFlagsArray.Remove(comp.componentName);
                    string[] compNamesArray = new string[] { comp.componentName }.Concat(compFlagsArray).ToArray();
                    int      selectedComponent = 0;
                    selectedComponent = EditorGUILayout.Popup(selectedComponent, compNamesArray, GUILayout.MinWidth(minColumnWidth), GUILayout.MaxWidth(maxColumnWidth));
                    if (selectedComponent != 0)
                    {
                        volumeLines.Add(new NewLineContainer(effect, compNamesArray[selectedComponent]));
                        fieldsToDelete.Add(field);
                        dirtyVolumeFlags = true;
                    }

                    FieldInfo[] fieldArray      = AmplifyColor.VolumeEffectComponent.ListAcceptableFields(c);
                    string[]    fieldFlagsArray = fieldArray.Select(s => s.Name).ToArray();
                    string[]    fieldNamesArray = comp.GetFieldNames();
                    fieldFlagsArray = fieldFlagsArray.Except(fieldNamesArray).ToArray();

                    List <string> names = new List <string>();
                    names.Add(field.fieldName);
                    names.AddRange(fieldFlagsArray);
                    for (int i = 0; i < names.Count; i++)
                    {
                        if (i == 0)
                        {
                            continue;
                        }

                        FieldInfo fi = Array.Find(fieldArray, s => (names[i] == s.Name));
                        if (fi != null)
                        {
                            names[i] += " : " + fi.FieldType.Name;
                        }
                    }

                    int selectedField = 0;
                    selectedField = EditorGUILayout.Popup(selectedField, names.ToArray(), GUILayout.MinWidth(minColumnWidth), GUILayout.MaxWidth(maxColumnWidth));
                    if (selectedField != 0)
                    {
                        fieldsToAdd.Add(new KeyValuePair <string, int>(fieldFlagsArray[selectedField - 1], fieldPosition));
                        fieldsToDelete.Add(field);
                        dirtyVolumeFlags = true;
                    }
                    fieldPosition++;

                    switch (field.fieldType)
                    {
                    case "System.Single": field.valueSingle = EditorGUILayout.FloatField(field.valueSingle, GUILayout.MinWidth(minValueWidth), GUILayout.MaxWidth(maxValueWidth)); break;

                    case "System.Boolean": field.valueBoolean = EditorGUILayout.Toggle("", field.valueBoolean, GUILayout.MinWidth(minValueWidth), GUILayout.MaxWidth(maxValueWidth)); break;

                    case "UnityEngine.Vector2": field.valueVector2 = EditorGUILayout.Vector2Field("", field.valueVector2, GUILayout.MinWidth(minValueWidth), GUILayout.MaxWidth(maxValueWidth), GUILayout.MaxHeight(16)); break;

                    case "UnityEngine.Vector3": field.valueVector3 = EditorGUILayout.Vector3Field("", field.valueVector3, GUILayout.MinWidth(minValueWidth), GUILayout.MaxWidth(maxValueWidth), GUILayout.MaxHeight(16)); break;

                    case "UnityEngine.Vector4": field.valueVector4 = DrawFixedVector4Field(field.valueVector4); break;

                    case "UnityEngine.Color": field.valueColor = EditorGUILayout.ColorField(field.valueColor, GUILayout.MinWidth(minValueWidth), GUILayout.MaxWidth(maxValueWidth)); break;

                    default: EditorGUILayout.LabelField(field.fieldType, GUILayout.MinWidth(minValueWidth), GUILayout.MaxWidth(maxValueWidth)); break;
                    }

                    // COPY TO CLIPBOARD
                    string luid   = NewLineContainer.GenerateUniqueID(effect, comp.componentName, field.fieldName);
                    bool   copied = copyLines.ContainsKey(luid);
                    bool   keep   = GUILayout.Toggle(copied, "c", removeButtonStyle, GUILayout.Width(removeButtonSize), GUILayout.Height(removeButtonSize));
                    if (keep != copied)
                    {
                        if (keep)
                        {
                            object valueCopy = null;
                            switch (field.fieldType)
                            {
                            case "System.Single": valueCopy = field.valueSingle; break;

                            case "System.Boolean": valueCopy = field.valueBoolean; break;

                            case "UnityEngine.Vector2": valueCopy = field.valueVector2; break;

                            case "UnityEngine.Vector3": valueCopy = field.valueVector3; break;

                            case "UnityEngine.Vector4": valueCopy = field.valueVector4; break;

                            case "UnityEngine.Color": valueCopy = field.valueColor; break;
                            }
                            copyLines.Add(luid, new NewLineContainer(effect, comp.componentName, field.fieldName, field.fieldType, valueCopy));
                        }
                        else
                        {
                            copyLines.Remove(luid);
                        }

                        //Debug.Log( "CopyComplete: " + luid + ", " + keep + ", " + volume.name );
                    }

                    EditorGUILayout.EndHorizontal();
                    GUILayout.Space(2);
                }

                bool fieldRemoved = false;
                foreach (AmplifyColor.VolumeEffectField field in fieldsToDelete)
                {
                    comp.RemoveEffectField(field);
                    fieldRemoved = true;
                }

                foreach (KeyValuePair <string, int> pair in fieldsToAdd)
                {
                    FieldInfo pi = c.GetType().GetField(pair.Key);
                    if (pi != null)
                    {
                        comp.AddField(pi, c, pair.Value);
                    }
                }

                if (fieldRemoved && comp.fields.Count <= 0)
                {
                    compsToDelete.Add(comp);
                }
            }

            bool compRemoved = false;
            foreach (AmplifyColor.VolumeEffectComponent comp in compsToDelete)
            {
                effectVol.RemoveEffectComponent(comp);
                compRemoved = true;
            }

            if (compRemoved && effectVol.components.Count <= 0)
            {
                effectsToDelete.Add(effectVol);
            }
        }

        foreach (AmplifyColor.VolumeEffect effectVol in effectsToDelete)
        {
            volume.EffectContainer.RemoveVolumeEffect(effectVol);
        }
        #endregion CurrentEffectFields

        #region NewLines
        List <NewLineContainer> linesToDelete = new List <NewLineContainer>();
        foreach (NewLineContainer line in volumeLines)
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.MinWidth(minIndentWidth), GUILayout.MaxWidth(maxIndentWidth));
            GUILayout.Space(0);

            if (GUILayout.Button("", minusStyle, GUILayout.MinWidth(18), GUILayout.MaxWidth(18), GUILayout.Height(20)))
            {
                linesToDelete.Add(line);
            }

            Camera           selectedCamera = EditorGUILayout.ObjectField(line.camera, typeof(Camera), true, GUILayout.MinWidth(minColumnWidth * 1.5f), GUILayout.MaxWidth(maxColumnWidth * 1.5f)) as Camera;
            AmplifyColorBase selectedEffect = (selectedCamera != null) ? selectedCamera.GetComponent <AmplifyColorBase>() : null;
            if (selectedEffect != null && selectedEffect != line.camera)
            {
                line.SetCamera(selectedEffect);
            }

            AmplifyColor.VolumeEffect effectVol = null;
            if (line.camera != null)
            {
                effectVol = volume.EffectContainer.FindVolumeEffect(line.camera);
            }

            if (line.camera != null)
            {
                Component[]   compArray     = AmplifyColor.VolumeEffect.ListAcceptableComponents(line.camera);
                List <string> names         = compArray.Select(s => s.GetType().Name).ToList <string>();
                int           popupSelected = names.IndexOf(line.component) + 1;
                names.Insert(0, "<Component>");
                int selectedComponent = popupSelected;
                selectedComponent = EditorGUILayout.Popup(selectedComponent, names.ToArray(), GUILayout.MinWidth(minColumnWidth), GUILayout.MaxWidth(maxColumnWidth));
                if (selectedComponent != popupSelected)
                {
                    line.SetComponent(selectedComponent == 0 ? null : names[selectedComponent]);
                }
            }
            else
            {
                GUI.enabled = false;
                EditorGUILayout.Popup(0, new string[] { "<Component>" }, GUILayout.MaxWidth(maxColumnWidth));
                GUI.enabled = true;
            }

            Component c = (line.camera == null) ? null : line.camera.GetComponent(line.component);

            AmplifyColor.VolumeEffectComponent comp = null;
            if (effectVol != null)
            {
                comp = effectVol.FindEffectComponent(line.component);
            }

            if (c != null)
            {
                FieldInfo[] fieldArray      = AmplifyColor.VolumeEffectComponent.ListAcceptableFields(c);
                string[]    fieldFlagsArray = fieldArray.Select(s => s.Name).ToArray();
                if (comp != null)
                {
                    string[] fieldNamesArray = comp.GetFieldNames();
                    fieldFlagsArray = fieldFlagsArray.Except(fieldNamesArray).ToArray();
                }

                List <string> names = fieldFlagsArray.ToList();
                for (int i = 0; i < names.Count; i++)
                {
                    FieldInfo fi = Array.Find(fieldArray, s => (names[i] == s.Name));
                    if (fi != null)
                    {
                        names[i] += " : " + fi.FieldType.Name;
                    }
                }
                names.Insert(0, "<Field>");

                int selectedField = 0;
                selectedField = EditorGUILayout.Popup(selectedField, names.ToArray(), GUILayout.MinWidth(minColumnWidth), GUILayout.MaxWidth(maxColumnWidth));
                if (selectedField > 0)
                {
                    FieldInfo pi = c.GetType().GetField(fieldFlagsArray[selectedField - 1]);
                    if (pi != null)
                    {
                        if (effectVol == null)
                        {
                            effectVol = volume.EffectContainer.AddJustColorEffect(line.camera);
                        }

                        if (comp == null)
                        {
                            comp = effectVol.AddComponent(c, null);
                        }

                        comp.AddField(pi, c);
                        linesToDelete.Add(line);
                        dirtyVolumeFlags = true;
                    }
                }

                EditorGUILayout.LabelField("", GUILayout.MinWidth(minValueWidth), GUILayout.MaxWidth(maxValueWidth));
            }
            else
            {
                GUI.enabled = false;
                EditorGUILayout.Popup(0, new string[] { "<Field>" }, GUILayout.MaxWidth(maxColumnWidth));
                EditorGUILayout.TextField("", GUILayout.MinWidth(minValueWidth), GUILayout.MaxWidth(maxValueWidth));
                GUI.enabled = true;
            }

            if (line.camera != null)
            {
                string luid   = NewLineContainer.GenerateUniqueID(line.camera, line.component, line.fieldName);
                bool   copied = copyLines.ContainsKey(luid);
                bool   keep   = GUILayout.Toggle(copied, "c", removeButtonStyle, GUILayout.Width(removeButtonSize), GUILayout.Height(removeButtonSize));
                if (keep != copied)
                {
                    if (keep)
                    {
                        copyLines.Add(luid, new NewLineContainer(line.camera, line.component, line.fieldName, line.fieldType, line.value));
                    }
                    else
                    {
                        copyLines.Remove(luid);
                    }

                    //Debug.Log( "CopyIncomplete: " + luid + ", " + keep + ", " + volume.name );
                }
            }
            else
            {
                GUI.enabled = false;
                GUILayout.Button("c", removeButtonStyle, GUILayout.Width(removeButtonSize), GUILayout.Height(removeButtonSize));
                GUI.enabled = true;
            }

            EditorGUILayout.EndHorizontal();
            GUILayout.Space(2);
        }

        foreach (NewLineContainer line in linesToDelete)
        {
            copyLines.Remove(line.GenerateUniqueID());
            //Debug.Log( "Removed " + line.GenerateUniqueID() );
            volumeLines.Remove(line);
        }
        #endregion NewLines

        #region AddPaste
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("", GUILayout.MinWidth(minIndentWidth), GUILayout.MaxWidth(maxIndentWidth));
        GUILayout.Space(0);

        bool add = GUILayout.Button("", plusStyle, GUILayout.MinWidth(18), GUILayout.MaxWidth(18), GUILayout.Height(20));
        if (add || GUILayout.Button("Add New", GUILayout.MinWidth(minColumnWidth), GUILayout.MaxWidth(maxColumnWidth), GUILayout.Height(20)))
        {
            volumeLines.Add(new NewLineContainer());
        }

        GUI.enabled = (copyLines.Count > 0);
        if (GUILayout.Button("Paste", GUILayout.MinWidth(minColumnWidth), GUILayout.MaxWidth(maxColumnWidth), GUILayout.Height(20)))
        {
            foreach (var pair in copyLines)
            {
                NewLineContainer line = pair.Value;
                Component        c    = (line.camera == null) ? null : line.camera.GetComponent(line.component);
                FieldInfo        pi   = (c != null) ? c.GetType().GetField(line.fieldName) : null;

                if (pi == null)
                {
                    volumeLines.Add(new NewLineContainer(line.camera, line.component, line.fieldName, line.fieldType, line.value));
                }
                else
                {
                    AmplifyColor.VolumeEffect effectVol = volume.EffectContainer.FindVolumeEffect(line.camera);
                    if (effectVol == null)
                    {
                        effectVol = volume.EffectContainer.AddJustColorEffect(line.camera);
                    }

                    AmplifyColor.VolumeEffectComponent comp = effectVol.FindEffectComponent(line.component);
                    if (comp == null)
                    {
                        comp = effectVol.AddComponent(c, null);
                    }

                    AmplifyColor.VolumeEffectField field = comp.FindEffectField(line.fieldName);
                    if (field == null)
                    {
                        field = comp.AddField(pi, c);
                    }
                    else
                    {
                        Debug.LogWarning("[AmplifyColor] Blend Effect field already added to Volume " + volume.name + ".");
                    }

                    field.UpdateValue(line.value);
                }
            }

            dirtyVolumeFlags = true;
        }
        GUI.enabled = true;

        EditorGUILayout.EndHorizontal();
        GUILayout.Space(5);
        #endregion AddPaste
    }
Esempio n. 41
0
 private void UpdateVolumes()
 {
     if (this.volumesBlending)
     {
         this.currentVolumeEffects.BlendValues(this, this.blendVolumeEffects, this.effectVolumesBlendAdjusted);
     }
     Transform transform = (!(this.TriggerVolumeProxy == null)) ? this.TriggerVolumeProxy : base.transform;
     if (this.actualTriggerProxy.transform.parent != transform)
     {
         this.actualTriggerProxy.Reference = transform;
         this.actualTriggerProxy.gameObject.layer = transform.gameObject.layer;
     }
     AmplifyColorVolumeBase amplifyColorVolumeBase = null;
     int num = -2147483648;
     foreach (AmplifyColorVolumeBase current in this.enteredVolumes)
     {
         if (current.Priority > num)
         {
             amplifyColorVolumeBase = current;
             num = current.Priority;
         }
     }
     if (amplifyColorVolumeBase != this.currentVolumeLut)
     {
         this.currentVolumeLut = amplifyColorVolumeBase;
         Texture texture = (!(amplifyColorVolumeBase == null)) ? amplifyColorVolumeBase.LutTexture : this.worldLUT;
         float num2 = (!(amplifyColorVolumeBase == null)) ? amplifyColorVolumeBase.EnterBlendTime : this.ExitVolumeBlendTime;
         if (this.volumesBlending && !this.blendingFromMidBlend && texture == this.LutTexture)
         {
             this.LutTexture = this.volumesLutBlendTexture;
             this.volumesLutBlendTexture = texture;
             this.volumesBlendingTimeCountdown = num2 * ((this.volumesBlendingTime - this.volumesBlendingTimeCountdown) / this.volumesBlendingTime);
             this.volumesBlendingTime = num2;
             this.currentVolumeEffects = VolumeEffect.BlendValuesToVolumeEffect(this.EffectFlags, this.currentVolumeEffects, this.blendVolumeEffects, this.effectVolumesBlendAdjusted);
             this.effectVolumesBlendAdjust = 1f - this.volumesBlendAmount;
             this.volumesBlendAmount = 1f - this.volumesBlendAmount;
         }
         else
         {
             if (this.volumesBlending)
             {
                 this.materialBlendCache.SetFloat("_lerpAmount", this.volumesBlendAmount);
                 if (this.blendingFromMidBlend)
                 {
                     Graphics.Blit(this.midBlendLUT, this.blendCacheLut);
                     this.materialBlendCache.SetTexture("_RgbTex", this.blendCacheLut);
                 }
                 else
                 {
                     this.materialBlendCache.SetTexture("_RgbTex", this.LutTexture);
                 }
                 this.materialBlendCache.SetTexture("_LerpRgbTex", (!(this.volumesLutBlendTexture != null)) ? this.defaultLut : this.volumesLutBlendTexture);
                 Graphics.Blit(this.midBlendLUT, this.midBlendLUT, this.materialBlendCache);
                 this.blendCacheLut.DiscardContents();
                 this.currentVolumeEffects = VolumeEffect.BlendValuesToVolumeEffect(this.EffectFlags, this.currentVolumeEffects, this.blendVolumeEffects, this.effectVolumesBlendAdjusted);
                 this.effectVolumesBlendAdjust = 0f;
                 this.blendingFromMidBlend = true;
             }
             this.VolumesBlendTo(texture, num2);
         }
         this.blendVolumeEffects = ((!(amplifyColorVolumeBase == null)) ? amplifyColorVolumeBase.EffectContainer.GetVolumeEffect(this) : this.worldVolumeEffects);
         if (this.blendVolumeEffects == null)
         {
             this.blendVolumeEffects = this.worldVolumeEffects;
         }
     }
 }
Esempio n. 42
0
        public void BlendValues( AmplifyColorBase targetColor, VolumeEffect other, float blendAmount )
        {
            VolumeEffectFlags effectFlags = targetColor.EffectFlags;
            GameObject go = targetColor.gameObject;
            foreach ( VolumeEffectComponentFlags compFlags in effectFlags.components )
            {
            if ( !compFlags.blendFlag )
                continue;

            Component c = go.GetComponent( compFlags.componentName );
            VolumeEffectComponent effectComp = components.Find( s => s.componentName == compFlags.componentName );
            VolumeEffectComponent effectCompOther = other.components.Find( s => s.componentName == compFlags.componentName );
            if ( c == null || effectComp == null || effectCompOther == null )
                continue;

            foreach ( VolumeEffectFieldFlags fieldFlags in compFlags.componentFields )
            {
                if ( !fieldFlags.blendFlag )
                    continue;

            #if !UNITY_EDITOR && UNITY_METRO
                FieldInfo fi = c.GetType().GetRuntimeField(fieldFlags.fieldName);
            #else
                FieldInfo fi = c.GetType().GetField( fieldFlags.fieldName );
            #endif
                VolumeEffectField effectField = effectComp.fields.Find( s => s.fieldName == fieldFlags.fieldName );
                VolumeEffectField effectFieldOther = effectCompOther.fields.Find( s => s.fieldName == fieldFlags.fieldName );

                if ( fi == null || effectField == null || effectFieldOther == null )
                    continue;

                switch ( fi.FieldType.FullName )
                {
                    case "System.Single": fi.SetValue( c, Mathf.Lerp( effectField.valueSingle, effectFieldOther.valueSingle, blendAmount ) ); break;
                    case "System.Boolean": fi.SetValue( c, effectFieldOther.valueBoolean ); break;
                    case "UnityEngine.Vector2": fi.SetValue( c, Vector2.Lerp( effectField.valueVector2, effectFieldOther.valueVector2, blendAmount ) ); break;
                    case "UnityEngine.Vector3": fi.SetValue( c, Vector3.Lerp( effectField.valueVector3, effectFieldOther.valueVector3, blendAmount ) ); break;
                    case "UnityEngine.Vector4": fi.SetValue( c, Vector4.Lerp( effectField.valueVector4, effectFieldOther.valueVector4, blendAmount ) ); break;
                    case "UnityEngine.Color": fi.SetValue( c, Color.Lerp( effectField.valueColor, effectFieldOther.valueColor, blendAmount ) ); break;
                }
            }
            }
        }
Esempio n. 43
0
        public static VolumeEffect BlendValuesToVolumeEffect(VolumeEffectFlags flags, VolumeEffect volume1, VolumeEffect volume2, float blend)
        {
            VolumeEffect volumeEffect = new VolumeEffect(volume1.gameObject);

            foreach (VolumeEffectComponentFlags volumeEffectComponentFlags in flags.components)
            {
                if (volumeEffectComponentFlags.blendFlag)
                {
                    VolumeEffectComponent volumeEffectComponent  = volume1.FindEffectComponent(volumeEffectComponentFlags.componentName);
                    VolumeEffectComponent volumeEffectComponent2 = volume2.FindEffectComponent(volumeEffectComponentFlags.componentName);
                    if (volumeEffectComponent != null && volumeEffectComponent2 != null)
                    {
                        VolumeEffectComponent volumeEffectComponent3 = new VolumeEffectComponent(volumeEffectComponent.componentName);
                        foreach (VolumeEffectFieldFlags volumeEffectFieldFlags in volumeEffectComponentFlags.componentFields)
                        {
                            if (volumeEffectFieldFlags.blendFlag)
                            {
                                VolumeEffectField volumeEffectField  = volumeEffectComponent.FindEffectField(volumeEffectFieldFlags.fieldName);
                                VolumeEffectField volumeEffectField2 = volumeEffectComponent2.FindEffectField(volumeEffectFieldFlags.fieldName);
                                if (volumeEffectField != null && volumeEffectField2 != null)
                                {
                                    VolumeEffectField volumeEffectField3 = new VolumeEffectField(volumeEffectField.fieldName, volumeEffectField.fieldType);
                                    string            fieldType          = volumeEffectField3.fieldType;
                                    if (fieldType != null)
                                    {
                                        if (!(fieldType == "System.Single"))
                                        {
                                            if (!(fieldType == "System.Boolean"))
                                            {
                                                if (!(fieldType == "UnityEngine.Vector2"))
                                                {
                                                    if (!(fieldType == "UnityEngine.Vector3"))
                                                    {
                                                        if (!(fieldType == "UnityEngine.Vector4"))
                                                        {
                                                            if (fieldType == "UnityEngine.Color")
                                                            {
                                                                volumeEffectField3.valueColor = Color.Lerp(volumeEffectField.valueColor, volumeEffectField2.valueColor, blend);
                                                            }
                                                        }
                                                        else
                                                        {
                                                            volumeEffectField3.valueVector4 = Vector4.Lerp(volumeEffectField.valueVector4, volumeEffectField2.valueVector4, blend);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        volumeEffectField3.valueVector3 = Vector3.Lerp(volumeEffectField.valueVector3, volumeEffectField2.valueVector3, blend);
                                                    }
                                                }
                                                else
                                                {
                                                    volumeEffectField3.valueVector2 = Vector2.Lerp(volumeEffectField.valueVector2, volumeEffectField2.valueVector2, blend);
                                                }
                                            }
                                            else
                                            {
                                                volumeEffectField3.valueBoolean = volumeEffectField2.valueBoolean;
                                            }
                                        }
                                        else
                                        {
                                            volumeEffectField3.valueSingle = Mathf.Lerp(volumeEffectField.valueSingle, volumeEffectField2.valueSingle, blend);
                                        }
                                    }
                                    volumeEffectComponent3.fields.Add(volumeEffectField3);
                                }
                            }
                        }
                        volumeEffect.components.Add(volumeEffectComponent3);
                    }
                }
            }
            return(volumeEffect);
        }
Esempio n. 44
0
 public void AddColorEffect( AmplifyColorBase colorEffect )
 {
     VolumeEffect volume;
     if ( ( volume = volumes.Find( s => s.gameObject == colorEffect ) ) != null )
     volume.UpdateVolume();
     else
     {
     volume = new VolumeEffect( colorEffect );
     volumes.Add( volume );
     volume.UpdateVolume();
     }
 }
Esempio n. 45
0
        public void BlendValues(AmplifyColorBase targetColor, VolumeEffect other, float blendAmount)
        {
            VolumeEffectFlags effectFlags = targetColor.EffectFlags;
            GameObject        gameObject  = targetColor.gameObject;

            for (int i = 0; i < effectFlags.components.Count; i++)
            {
                VolumeEffectComponentFlags volumeEffectComponentFlags = effectFlags.components[i];
                if (volumeEffectComponentFlags.blendFlag)
                {
                    Component             component              = gameObject.GetComponent(volumeEffectComponentFlags.componentName);
                    VolumeEffectComponent volumeEffectComponent  = this.FindEffectComponent(volumeEffectComponentFlags.componentName);
                    VolumeEffectComponent volumeEffectComponent2 = other.FindEffectComponent(volumeEffectComponentFlags.componentName);
                    if (!(component == null) && volumeEffectComponent != null && volumeEffectComponent2 != null)
                    {
                        for (int j = 0; j < volumeEffectComponentFlags.componentFields.Count; j++)
                        {
                            VolumeEffectFieldFlags volumeEffectFieldFlags = volumeEffectComponentFlags.componentFields[j];
                            if (volumeEffectFieldFlags.blendFlag)
                            {
                                FieldInfo         field              = component.GetType().GetField(volumeEffectFieldFlags.fieldName);
                                VolumeEffectField volumeEffectField  = volumeEffectComponent.FindEffectField(volumeEffectFieldFlags.fieldName);
                                VolumeEffectField volumeEffectField2 = volumeEffectComponent2.FindEffectField(volumeEffectFieldFlags.fieldName);
                                if (field != null && volumeEffectField != null && volumeEffectField2 != null)
                                {
                                    string fullName = field.FieldType.FullName;
                                    if (fullName != null)
                                    {
                                        if (!(fullName == "System.Single"))
                                        {
                                            if (!(fullName == "System.Boolean"))
                                            {
                                                if (!(fullName == "UnityEngine.Vector2"))
                                                {
                                                    if (!(fullName == "UnityEngine.Vector3"))
                                                    {
                                                        if (!(fullName == "UnityEngine.Vector4"))
                                                        {
                                                            if (fullName == "UnityEngine.Color")
                                                            {
                                                                field.SetValue(component, Color.Lerp(volumeEffectField.valueColor, volumeEffectField2.valueColor, blendAmount));
                                                            }
                                                        }
                                                        else
                                                        {
                                                            field.SetValue(component, Vector4.Lerp(volumeEffectField.valueVector4, volumeEffectField2.valueVector4, blendAmount));
                                                        }
                                                    }
                                                    else
                                                    {
                                                        field.SetValue(component, Vector3.Lerp(volumeEffectField.valueVector3, volumeEffectField2.valueVector3, blendAmount));
                                                    }
                                                }
                                                else
                                                {
                                                    field.SetValue(component, Vector2.Lerp(volumeEffectField.valueVector2, volumeEffectField2.valueVector2, blendAmount));
                                                }
                                            }
                                            else
                                            {
                                                field.SetValue(component, volumeEffectField2.valueBoolean);
                                            }
                                        }
                                        else
                                        {
                                            field.SetValue(component, Mathf.Lerp(volumeEffectField.valueSingle, volumeEffectField2.valueSingle, blendAmount));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 46
0
 public void RemoveVolumeEffect( VolumeEffect volume )
 {
     volumes.Remove( volume );
 }
        public VolumeEffect FindVolumeEffect(AmplifyColorBase colorEffect) => default;   // 0x0085F330-0x0085F4E0

        public void RemoveVolumeEffect(VolumeEffect volume)
        {
        }                                                              // 0x0085F5D0-0x0085F630