Created
June 2, 2015 02:29
-
-
Save thedoritos/6d7391b11fbc7005d91d to your computer and use it in GitHub Desktop.
Selecting Image Effects written in JS from C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[RequireComponent(typeof(Camera))] | |
public class CameraEffectSwitcher : MonoBehaviour | |
{ | |
Dictionary<CameraEffectType, MonoBehaviour> cameraEffectComponents = new Dictionary<CameraEffectType, MonoBehaviour>(); | |
void Awake() | |
{ | |
var components = GetComponents<Component>().Where(c => { | |
return c.GetType().ToString().Equals("ColorCorrectionCurves"); | |
}).Select(c => { | |
return c as MonoBehaviour; | |
}).ToList(); | |
cameraEffectComponents.Add(CameraEffectType.One, components[0]); | |
cameraEffectComponents.Add(CameraEffectType.Two, components[1]); | |
cameraEffectComponents.Add(CameraEffectType.Three, components[2]); | |
} | |
public void Apply(CameraEffectType cameraEffectType) | |
{ | |
cameraEffectComponents.Values.ToList().ForEach(e => e.enabled = false); | |
if (cameraEffectComponents.ContainsKey(cameraEffectType)) | |
{ | |
cameraEffectComponents[cameraEffectType].enabled = true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment