예제 #1
0
        public VolumeEffect AddJustColorEffect(AmplifyColorBase colorEffect)
        {
            VolumeEffect volumeEffect = new VolumeEffect(colorEffect);

            this.volumes.Add(volumeEffect);
            return(volumeEffect);
        }
예제 #2
0
    bool FindClone(AmplifyColorBase effect)
    {
        #if UNITY_2018_1_OR_NEWER
        GameObject           effectPrefab               = PrefabUtility.GetCorrespondingObjectFromSource(effect.gameObject) as GameObject;
        PrefabAssetType      effectPrefabType           = PrefabUtility.GetPrefabAssetType(effect.gameObject);
        PrefabInstanceStatus effectPrefabInstanceStatus = PrefabUtility.GetPrefabInstanceStatus(effect.gameObject);
        bool effectIsPrefab = (effectPrefabType != PrefabAssetType.NotAPrefab && effectPrefabInstanceStatus == PrefabInstanceStatus.NotAPrefab);
        #else
        GameObject effectPrefab     = PrefabUtility.GetPrefabParent(effect.gameObject) as GameObject;
        PrefabType effectPrefabType = PrefabUtility.GetPrefabType(effect.gameObject);
        bool       effectIsPrefab   = (effectPrefabType != PrefabType.None && effectPrefabType != PrefabType.PrefabInstance);
        #endif
        bool effectHasPrefab = (effectPrefab != null);

        AmplifyColorBase[] all = Resources.FindObjectsOfTypeAll(typeof(AmplifyColorBase)) as AmplifyColorBase[];
        bool foundClone        = false;

        foreach (AmplifyColorBase other in all)
        {
            if (other == effect || other.SharedInstanceID != effect.SharedInstanceID)
            {
                // skip: same effect or already have different ids
                continue;
            }

                #if UNITY_2018_1_OR_NEWER
            GameObject           otherPrefab               = PrefabUtility.GetCorrespondingObjectFromSource(other.gameObject) as GameObject;
            PrefabAssetType      otherPrefabType           = PrefabUtility.GetPrefabAssetType(other.gameObject);
            PrefabInstanceStatus otherPrefabInstanceStatus = PrefabUtility.GetPrefabInstanceStatus(other.gameObject);
            bool otherIsPrefab = (otherPrefabType != PrefabAssetType.NotAPrefab && otherPrefabInstanceStatus == PrefabInstanceStatus.NotAPrefab);
                #else
            GameObject otherPrefab     = PrefabUtility.GetPrefabParent(other.gameObject) as GameObject;
            PrefabType otherPrefabType = PrefabUtility.GetPrefabType(other.gameObject);
            bool       otherIsPrefab   = (otherPrefabType != PrefabType.None && otherPrefabType != PrefabType.PrefabInstance);
                #endif
            bool otherHasPrefab = (otherPrefab != null);

            if (otherIsPrefab && effectHasPrefab && effectPrefab == other.gameObject)
            {
                // skip: other is a prefab and effect's prefab is other
                continue;
            }

            if (effectIsPrefab && otherHasPrefab && otherPrefab == effect.gameObject)
            {
                // skip: effect is a prefab and other's prefab is effect
                continue;
            }

            if (!effectIsPrefab && !otherIsPrefab && effectHasPrefab && otherHasPrefab && effectPrefab == otherPrefab)
            {
                // skip: both aren't prefabs and both have the same parent prefab
                continue;
            }

            foundClone = true;
        }

        return(foundClone);
    }
        public VolumeEffect AddJustColorEffect(AmplifyColorBase colorEffect)
        {
            VolumeEffect created = new VolumeEffect(colorEffect);

            volumes.Add(created);
            return(created);
        }
예제 #4
0
        public void BlendValues(AmplifyColorBase 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;
                    }
                }
            }
        }
	public NewLineContainer( AmplifyColorBase camera, string component, string fieldName, string fieldType, object value )
	{
		this.camera = camera;
		this.component = component;
		this.fieldName = fieldName;
		this.fieldType = fieldType;
		this.value = value;
	}
	public void SetCamera( AmplifyColorBase camera )
	{
		this.camera = camera;
		component = "";
		fieldName = "";
		fieldType = "";
		value = null;
	}
 public NewLineContainer(AmplifyColorBase camera, string component, string fieldName, string fieldType, object value)
 {
     this.camera    = camera;
     this.component = component;
     this.fieldName = fieldName;
     this.fieldType = fieldType;
     this.value     = value;
 }
 public void SetCamera(AmplifyColorBase camera)
 {
     this.camera = camera;
     component   = "";
     fieldName   = "";
     fieldType   = "";
     value       = null;
 }
예제 #9
0
        public static Component[] ListAcceptableComponents( AmplifyColorBase go )
        {
            if ( go == null )
            return new Component[ 0 ];

            Component[] comps = go.GetComponents( typeof( Component ) );
            return ( comps.Where( comp => comp != null && ( !( ( comp.GetType() + "" ).StartsWith( "UnityEngine." ) || comp.GetType() == typeof( AmplifyColorBase ) ) ) ) ).ToArray();
        }
예제 #10
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;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #11
0
 public static Component[] ListAcceptableComponents(AmplifyColorBase go)
 {
     if (go == null)
     {
         return(new Component[0]);
     }
     return((from comp in go.GetComponents(typeof(Component))
             where comp != null && !string.Concat(comp.GetType()).StartsWith("UnityEngine.") && !(comp.GetType() == typeof(AmplifyColorBase))
             select comp).ToArray <Component>());
 }
예제 #12
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);
        }
        public static Component[] ListAcceptableComponents(AmplifyColorBase go)
        {
            if (go == null)
            {
                return(new Component[0]);
            }

            Component[] comps = go.GetComponents(typeof(Component));
            return((comps.Where(comp => comp != null && (!((comp.GetType() + "").StartsWith("UnityEngine.") || comp.GetType() == typeof(AmplifyColorBase))))).ToArray());
        }
예제 #14
0
        public void SetValues(AmplifyColorBase targetColor)
        {
            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);
                    if (!(component == null) && volumeEffectComponent != 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);
                                if (field != null && volumeEffectField != null)
                                {
                                    string fullName = field.FieldType.FullName;
                                    switch (fullName)
                                    {
                                    case "System.Single":
                                        field.SetValue(component, volumeEffectField.valueSingle);
                                        break;

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

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

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

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

                                    case "UnityEngine.Color":
                                        field.SetValue(component, volumeEffectField.valueColor);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #15
0
 public static Component[] ListAcceptableComponents(AmplifyColorBase go)
 {
     if (go == null)
     {
         return(new Component[0]);
     }
     Component[] source = go.GetComponents(typeof(Component));
     return((from comp in source
             where comp != null && (!(comp.GetType() + string.Empty).StartsWith("UnityEngine.") && comp.GetType() != typeof(AmplifyColorBase))
             select comp).ToArray <Component>());
 }
        public void SetValues(AmplifyColorBase targetColor)
        {
            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);
                if (c == null || effectComp == 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);
                    if (fi == null || effectField == null)
                    {
                        continue;
                    }

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

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

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

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

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

                    case "UnityEngine.Color": fi.SetValue(c, effectField.valueColor); break;
                    }
                }
            }
        }
예제 #17
0
 public override void OnStart()
 {
     base.OnStart();
     _amplifyCache = GameMainReferences.Instance.AmplifyColor;
     _playerEntity = GameMainReferences.Instance.PlayerController.Entity;
     _correctionCurve = GameMainReferences.Instance.RTSCamera.GetComponent<ColorCorrectionCurves>();
     if(LevelMetaInfo.Instance.StartLutTexture != null)
     {
         _amplifyCache.LutTexture = LevelMetaInfo.Instance.StartLutTexture;
         MainLutTexture = LevelMetaInfo.Instance.StartLutTexture;
     }
 }
예제 #18
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();
        }
예제 #19
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();
     }
 }
예제 #20
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();
            }
        }
        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();
            }
        }
예제 #22
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);
        }
    void OnEnable()
    {
        if (maskCamera == null)
        {
            var go = new GameObject("Mask Camera", typeof(Camera))
            {
                hideFlags = HideFlags.HideAndDontSave
            };
            go.transform.parent = gameObject.transform;
            maskCamera          = go.GetComponent <Camera>();
        }

        referenceCamera = GetComponent <Camera>();
        colorEffect     = GetComponent <AmplifyColorBase>();

        colorMaskShader = Shader.Find("Hidden/RenderMask");
    }
예제 #24
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);
             }
         }
     }
 }
	bool FindClone( AmplifyColorBase effect )
	{
		GameObject effectPrefab = PrefabUtility.GetPrefabParent( effect.gameObject ) as GameObject;
		PrefabType effectPrefabType = PrefabUtility.GetPrefabType( effect.gameObject );
		bool effectIsPrefab = ( effectPrefabType != PrefabType.None && effectPrefabType != PrefabType.PrefabInstance );
		bool effectHasPrefab = ( effectPrefab != null );

		AmplifyColorBase[] all = Resources.FindObjectsOfTypeAll( typeof( AmplifyColorBase ) ) as AmplifyColorBase[];
		bool foundClone = false;

		foreach ( AmplifyColorBase other in all )
		{
			if ( other == effect || other.SharedInstanceID != effect.SharedInstanceID )
			{
				// skip: same effect or already have different ids
				continue;
			}

			GameObject otherPrefab = PrefabUtility.GetPrefabParent( other.gameObject ) as GameObject;
			PrefabType otherPrefabType = PrefabUtility.GetPrefabType( other.gameObject );
			bool otherIsPrefab = ( otherPrefabType != PrefabType.None && otherPrefabType != PrefabType.PrefabInstance );
			bool otherHasPrefab = ( otherPrefab != null );

			if ( otherIsPrefab && effectHasPrefab && effectPrefab == other.gameObject )
			{
				// skip: other is a prefab and effect's prefab is other
				continue;
			}

			if ( effectIsPrefab && otherHasPrefab && otherPrefab == effect.gameObject )
			{
				// skip: effect is a prefab and other's prefab is effect
				continue;
			}

			if ( !effectIsPrefab && !otherIsPrefab && effectHasPrefab && otherHasPrefab && effectPrefab == otherPrefab )
			{
				// skip: both aren't prefabs and both have the same parent prefab
				continue;
			}

			foundClone = true;
		}

		return foundClone;
	}
예제 #26
0
 public VolumeEffect FindVolumeEffect(AmplifyColorBase colorEffect)
 {
     for (int i = 0; i < this.volumes.Count; i++)
     {
         if (this.volumes[i].gameObject == colorEffect)
         {
             return(this.volumes[i]);
         }
     }
     for (int j = 0; j < this.volumes.Count; j++)
     {
         if (this.volumes[j].gameObject != null && this.volumes[j].gameObject.SharedInstanceID == colorEffect.SharedInstanceID)
         {
             return(this.volumes[j]);
         }
     }
     return(null);
 }
        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);
        }
예제 #28
0
    void OnEnable()
    {
        if (!Application.isPlaying)
        {
            AmplifyColorBase effect = target as AmplifyColorBase;

            bool needsNewID = string.IsNullOrEmpty(effect.SharedInstanceID);
            if (!needsNewID)
            {
                needsNewID = FindClone(effect);
            }

            if (needsNewID)
            {
                effect.NewSharedInstanceID();
                EditorUtility.SetDirty(target);
                //Debug.Log( "Assigned new instance ID to " + effect.name + " => " + effect.SharedInstanceID );
            }
        }
    }
예제 #29
0
        public VolumeEffect FindVolumeEffect(AmplifyColorBase colorEffect)
        {
            // find by reference first
            for (int i = 0; i < volumes.Count; i++)
            {
                if (volumes[i].gameObject == colorEffect)
                {
                    return(volumes[i]);
                }
            }

            // in case reference fails, find by instance id (e.g. instantiated prefabs)
            for (int i = 0; i < volumes.Count; i++)
            {
                if (volumes[i].gameObject != null && volumes[i].gameObject.SharedInstanceID == colorEffect.SharedInstanceID)
                {
                    return(volumes[i]);
                }
            }

            // not found
            return(null);
        }
    void OnEnable()
    {
        tonemapper       = serializedObject.FindProperty("Tonemapper");
        exposure         = serializedObject.FindProperty("Exposure");
        linearWhitePoint = serializedObject.FindProperty("LinearWhitePoint");
        useDithering     = serializedObject.FindProperty("ApplyDithering");

        qualityLevel    = serializedObject.FindProperty("QualityLevel");
        blendAmount     = serializedObject.FindProperty("BlendAmount");
        lutTexture      = serializedObject.FindProperty("LutTexture");
        lutBlendTexture = serializedObject.FindProperty("LutBlendTexture");
        maskTexture     = serializedObject.FindProperty("MaskTexture");
        useDepthMask    = serializedObject.FindProperty("UseDepthMask");
        depthMaskCurve  = serializedObject.FindProperty("DepthMaskCurve");

        useVolumes          = serializedObject.FindProperty("UseVolumes");
        exitVolumeBlendTime = serializedObject.FindProperty("ExitVolumeBlendTime");
        triggerVolumeProxy  = serializedObject.FindProperty("TriggerVolumeProxy");
        volumeCollisionMask = serializedObject.FindProperty("VolumeCollisionMask");

        if (!Application.isPlaying)
        {
            AmplifyColorBase effect = target as AmplifyColorBase;

            bool needsNewID = string.IsNullOrEmpty(effect.SharedInstanceID);
            if (!needsNewID)
            {
                needsNewID = FindClone(effect);
            }

            if (needsNewID)
            {
                effect.NewSharedInstanceID();
                EditorUtility.SetDirty(target);
            }
        }
    }
	public NewLineContainer( AmplifyColorBase camera )
	{
		this.camera = camera;
	}
예제 #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;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
예제 #33
0
 public static string GenerateUniqueID(AmplifyColorBase camera, string component, string fieldName)
 {
     return(camera.GetInstanceID().ToString() + "." + component + "." + fieldName);
 }
예제 #34
0
 public void SetValues(AmplifyColorBase targetColor)
 {
     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);
             if (!(component == null) && volumeEffectComponent != 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);
                         if (field != null && volumeEffectField != null)
                         {
                             string fullName = field.FieldType.FullName;
                             switch (fullName)
                             {
                             case "System.Single":
                                 field.SetValue(component, volumeEffectField.valueSingle);
                                 break;
                             case "System.Boolean":
                                 field.SetValue(component, volumeEffectField.valueBoolean);
                                 break;
                             case "UnityEngine.Vector2":
                                 field.SetValue(component, volumeEffectField.valueVector2);
                                 break;
                             case "UnityEngine.Vector3":
                                 field.SetValue(component, volumeEffectField.valueVector3);
                                 break;
                             case "UnityEngine.Vector4":
                                 field.SetValue(component, volumeEffectField.valueVector4);
                                 break;
                             case "UnityEngine.Color":
                                 field.SetValue(component, volumeEffectField.valueColor);
                                 break;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
	public static string GenerateUniqueID( AmplifyColorBase camera, string component, string fieldName )
	{
		return camera.GetInstanceID().ToString() + "." + component + "." + fieldName;
	}
예제 #36
0
 public VolumeEffect AddJustColorEffect( AmplifyColorBase colorEffect )
 {
     VolumeEffect created = new VolumeEffect( colorEffect );
     volumes.Add( created );
     return created;
 }
예제 #37
0
 public VolumeEffect( AmplifyColorBase effect )
 {
     gameObject = effect;
     components = new List<VolumeEffectComponent>();
 }
예제 #38
0
 public VolumeEffect GetVolumeEffect(AmplifyColorBase colorEffect)
 {
     return(this.volumes.Find((VolumeEffect s) => s.gameObject == colorEffect));
 }
예제 #39
0
 public static Component[] ListAcceptableComponents(AmplifyColorBase go)
 {
     if (go == null)
     {
         return new Component[0];
     }
     Component[] source = go.GetComponents(typeof(Component));
     return (from comp in source
     where comp != null && (!(comp.GetType() + string.Empty).StartsWith("UnityEngine.") && comp.GetType() != typeof(AmplifyColorBase))
     select comp).ToArray<Component>();
 }
예제 #40
0
 public VolumeEffect GetVolumeEffect(AmplifyColorBase colorEffect)
 {
     return this.volumes.Find((VolumeEffect s) => s.gameObject == colorEffect);
 }
	public NewLineContainer( AmplifyColorBase camera, string component )
	{
		this.camera = camera;
		this.component = component;
	}
예제 #42
0
	public void BlendValues( AmplifyColorBase 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;
				}
			}
		}
	}
예제 #43
0
	public VolumeEffect FindVolumeEffect( AmplifyColorBase colorEffect )
	{
		// find by reference first
		for ( int i = 0; i < volumes.Count; i++ )
		{
			if ( volumes[ i ].gameObject == colorEffect )
				return volumes[ i ];
		}

		// in case reference fails, find by instance id (e.g. instantiated prefabs)
		for ( int i = 0; i < volumes.Count; i++ )
		{
			if ( volumes[ i ].gameObject != null && volumes[ i ].gameObject.SharedInstanceID == colorEffect.SharedInstanceID )
				return volumes[ i ];
		}

		// not found
		return null;
	}
	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 );
			}
		}
	}
예제 #45
0
    void DrawVolumeEffectFields(AmplifyColorVolume volume)
    {
        List <VolumeEffect> effectsToDelete = new List <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 (VolumeEffect effectVol in volume.EffectContainer.volumes)
        {
            if (effectVol.gameObject == null)
            {
                continue;
            }

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

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

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

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

                    AmplifyColorBase[]      effectArray = Resources.FindObjectsOfTypeAll(typeof(AmplifyColorBase)) as AmplifyColorBase[];
                    List <AmplifyColorBase> effectList  = effectArray.ToList();
                    int selectedEffect = -1;

                    if (effectArray.Count() > 0)
                    {
                        int popupSelected = effectList.IndexOf(effect);
                        selectedEffect = EditorGUILayout.Popup(popupSelected, (from e in effectList select e.gameObject.name).ToArray(), GUILayout.MinWidth(minColumnWidth), GUILayout.MaxWidth(maxColumnWidth));
                        if (selectedEffect != popupSelected)
                        {
                            fieldsToDelete.Add(field);
                            dirtyVolumeFlags = true;
                            volumeLines.Add(new NewLineContainer(effectList.ElementAtOrDefault(selectedEffect)));
                        }
                    }

                    Component[]   compArray      = 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      = 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 (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 (VolumeEffectComponent comp in compsToDelete)
            {
                effectVol.RemoveEffectComponent(comp);
                compRemoved = true;
            }

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

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

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

            AmplifyColorBase[]      colorEffectArray = Resources.FindObjectsOfTypeAll(typeof(AmplifyColorBase)) as AmplifyColorBase[];
            List <AmplifyColorBase> colorEffectList  = colorEffectArray.ToList();

            if (colorEffectArray.Count() > 0)
            {
                int           popupSelected  = (line.camera != null) ? colorEffectList.IndexOf(line.camera) + 1 : 0;
                int           selectedEffect = popupSelected;
                List <string> names          = (from e in colorEffectList select e.gameObject.name).ToList <string>();
                names.Insert(0, "<Camera>");
                selectedEffect = EditorGUILayout.Popup(selectedEffect, names.ToArray(), GUILayout.MinWidth(minColumnWidth), GUILayout.MaxWidth(maxColumnWidth));
                if (selectedEffect != popupSelected && selectedEffect > 0)
                {
                    line.SetCamera(colorEffectArray[selectedEffect - 1]);
                }
            }

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

            if (line.camera != null)
            {
                Component[]   compArray     = 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);

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

            if (c != null)
            {
                FieldInfo[] fieldArray      = 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

        #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
                {
                    VolumeEffect effectVol = volume.EffectContainer.GetVolumeEffect(line.camera);
                    if (effectVol == null)
                    {
                        effectVol = volume.EffectContainer.AddJustColorEffect(line.camera);
                    }

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

                    VolumeEffectField field = comp.GetEffectField(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
    }
예제 #46
0
        public void SetValues( AmplifyColorBase targetColor )
        {
            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 );
            if ( c == null || effectComp == 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 );
                if ( fi == null || effectField == null )
                    continue;

                switch ( fi.FieldType.FullName )
                {
                    case "System.Single": fi.SetValue( c, effectField.valueSingle ); break;
                    case "System.Boolean": fi.SetValue( c, effectField.valueBoolean ); break;
                    case "UnityEngine.Vector2": fi.SetValue( c, effectField.valueVector2 ); break;
                    case "UnityEngine.Vector3": fi.SetValue( c, effectField.valueVector3 ); break;
                    case "UnityEngine.Vector4": fi.SetValue( c, effectField.valueVector4 ); break;
                    case "UnityEngine.Color": fi.SetValue( c, effectField.valueColor ); break;
                }
            }
            }
        }
예제 #47
0
 public NewLineContainer(AmplifyColorBase camera)
 {
     this.camera = camera;
 }
예제 #48
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();
     }
 }
예제 #49
0
 public NewLineContainer(AmplifyColorBase camera, string component)
 {
     this.camera    = camera;
     this.component = component;
 }
예제 #50
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;
 }
예제 #51
0
 public VolumeEffect AddJustColorEffect(AmplifyColorBase colorEffect)
 {
     VolumeEffect volumeEffect = new VolumeEffect(colorEffect);
     this.volumes.Add(volumeEffect);
     return volumeEffect;
 }
예제 #52
0
        public bool ReadBackBuffer(out ImageResult imageResult)
        {
            imageResult = null;

            if (_cameras == null)
            {
                Debug.LogError("[AmplifyColor] Camera collection is invalid.");
                return(false);
            }

            var camera = _cameras.SelectedCamera;

            if (camera == null)
            {
                Debug.LogError("[AmplifyColor] Selected camera is invalid.");
                return(false);
            }

            AmplifyColorBase component            = camera.GetComponent <AmplifyColorBase>();
            Tonemapping      prevTonemapper       = Tonemapping.Disabled;
            float            prevExposure         = 1.0f;
            float            prevLinearWhitePoint = 11.2f;
            bool             prevApplyDithering   = false;
            float            prevBlendAmount      = 0.0f;
            Texture          prevLUT = null;

            if (component != null)
            {
                prevTonemapper       = component.Tonemapper;
                prevExposure         = component.Exposure;
                prevLinearWhitePoint = component.LinearWhitePoint;
                prevApplyDithering   = component.ApplyDithering;
                prevBlendAmount      = component.BlendAmount;
                prevLUT = component.LutTexture;

                component.Tonemapper       = ToolSettings.Instance.ApplyHDRControl ? component.Tonemapper : Tonemapping.Disabled;
                component.Exposure         = ToolSettings.Instance.ApplyHDRControl ? component.Exposure : 1.0f;
                component.LinearWhitePoint = ToolSettings.Instance.ApplyHDRControl ? component.LinearWhitePoint : 11.2f;
                component.ApplyDithering   = ToolSettings.Instance.ApplyHDRControl ? component.ApplyDithering : false;
                component.BlendAmount      = ToolSettings.Instance.ApplyColorGrading ? component.BlendAmount : 0.0f;
                component.LutTexture       = ToolSettings.Instance.ApplyColorGrading ? component.LutTexture : null;
            }

            var width  = ToolSettings.Instance.Resolution.TargetWidth;
            var height = ToolSettings.Instance.Resolution.TargetHeight;

            //if (ToolSettings.Instance.Resolution.IsGameWindowSize)
            //{
            //    width = Screen.width;
            //    height = Screen.height;
            //}

            var cameratarget = camera.targetTexture;

            var rt = RenderTexture.GetTemporary(width, height, 24, RenderTextureFormat.ARGB32);

            camera.targetTexture = rt;
            camera.Render();
            camera.targetTexture = cameratarget;

            var activert = RenderTexture.active;

            RenderTexture.active = rt;
            var text = new Texture2D(width, height, TextureFormat.ARGB32, false);

            text.ReadPixels(new Rect(0, 0, width, height), 0, 0);
            text.Apply();
            RenderTexture.active = activert;
            var colors = text.GetPixels(0, 0, width, height);

            Texture2D.DestroyImmediate(text);

            var colordata = new Color[width, height];

            for (int i = height - 1; i >= 0; i--)
            {
                for (int j = 0; j < width; j++)
                {
                    colordata[j, (height - 1 - i)]   = colors[i * width + j];
                    colordata[j, (height - 1 - i)].a = 1;
                }
            }

            if (component != null)
            {
                component.Tonemapper       = prevTonemapper;
                component.Exposure         = prevExposure;
                component.LinearWhitePoint = prevLinearWhitePoint;
                component.ApplyDithering   = prevApplyDithering;
                component.BlendAmount      = prevBlendAmount;
                component.LutTexture       = prevLUT;
            }

            imageResult = new ImageResult(colordata);

            return(true);
        }
	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;
	}