Beispiel #1
0
 void Start()
 {
     current                = GameObject.FindGameObjectWithTag(cameraTag).GetComponent <MobileColorGrading> ();
     temp                   = new MobileColorGrading();
     temp.Exposure          = current.Exposure;
     temp.Contrast          = current.Contrast;
     temp.Gamma             = current.Gamma;
     temp.Saturation        = current.Saturation;
     temp.vignetteIntensity = current.vignetteIntensity;
     temp.R                 = current.R;
     temp.G                 = current.G;
     temp.B                 = current.B;
 }
    public void Toggle_Effects()
    {
        effectsIsOn = !effectsIsOn;

        // Depth of Field
        DepthOfFieldDeprecated dof = GameObject.FindObjectOfType <DepthOfFieldDeprecated> ();

        if (dof)
        {
            dof.enabled = effectsIsOn;
        }

        // Bloom
        BloomOptimized bloom = GameObject.FindObjectOfType <BloomOptimized> ();

        if (bloom)
        {
            bloom.enabled = effectsIsOn;
        }


        // Sun Shaft
        SunShafts[] sunShaftS = GameObject.FindObjectsOfType <SunShafts> ();
        for (int a = 0; a < sunShaftS.Length; a++)
        {
            sunShaftS [a].enabled = effectsIsOn;
        }

        // Color Grading
        MobileColorGrading colorGrading = GameObject.FindObjectOfType <MobileColorGrading> ();

        if (colorGrading)
        {
            colorGrading.enabled = effectsIsOn;
        }
    }
    public void Update_ColorGrading(Camera mainCamera, bool enabled, ToneMapping mode, float exposure, float contrast, float gamma, float saturation, float r, float g, float b, float vignette)
    {
        if (enabled)
        {
            if (!mainCamera.GetComponent <MobileColorGrading> ())
            {
                mainCamera.gameObject.AddComponent <MobileColorGrading> ();
            }

            MobileColorGrading colorGrading = mainCamera.GetComponent <MobileColorGrading> ();
                        #if UNITY_EDITOR
            if (mainCamera.GetComponent <AudioListener> ())
            {
                UnityEditorInternal.ComponentUtility.MoveComponentDown(mainCamera.GetComponent <AudioListener> ());
            }

            if (mainCamera.GetComponent <MobileColorGrading> ())
            {
                UnityEditorInternal.ComponentUtility.MoveComponentDown(mainCamera.GetComponent <MobileColorGrading> ());
                UnityEditorInternal.ComponentUtility.MoveComponentDown(mainCamera.GetComponent <MobileColorGrading> ());
            }

            if (mainCamera.GetComponent <BloomOptimized> ())
            {
                UnityEditorInternal.ComponentUtility.MoveComponentDown(mainCamera.GetComponent <BloomOptimized> ());
                UnityEditorInternal.ComponentUtility.MoveComponentDown(mainCamera.GetComponent <BloomOptimized> ());
            }

            if (mainCamera.GetComponent <DepthOfFieldDeprecated> ())
            {
                UnityEditorInternal.ComponentUtility.MoveComponentDown(mainCamera.GetComponent <DepthOfFieldDeprecated> ());
                UnityEditorInternal.ComponentUtility.MoveComponentDown(mainCamera.GetComponent <DepthOfFieldDeprecated> ());
            }
                        #endif
            if (!colorGrading.shader)
            {
                colorGrading.shader = Shader.Find("Hidden/ALIyerEdon/ColorGrading");
            }
            colorGrading.Exposure          = exposure;
            colorGrading.toneMapping       = mode;
            colorGrading.Contrast          = contrast;
            colorGrading.Gamma             = gamma;
            colorGrading.Saturation        = saturation;
            colorGrading.R                 = r;
            colorGrading.G                 = g;
            colorGrading.B                 = b;
            colorGrading.vignetteIntensity = vignette;
        }
        else
        {
            if (mainCamera.GetComponent <MobileColorGrading> ())
            {
                if (Application.isPlaying)
                {
                    Destroy(mainCamera.GetComponent <MobileColorGrading> ());
                }
                else
                {
                    DestroyImmediate(mainCamera.GetComponent <MobileColorGrading> ());
                }
            }
        }
    }