Exemple #1
0
 /// <summary>
 /// Active Night Vision FX with specific NightVision FX using NightVision_Preset. By default, the timer apparition duration is set to 1 second.
 /// </summary>
 /// <param name="Preset">Use a specific NightVisionFX using NightVision_Preset.</param>
 public static void NightVision_ON(NightVision_Preset Preset)
 {
     if (CurrentCamera == null)
     {
         CurrentCamera = Camera.main;
     }
     if (CamNightVision != null)
     {
         return;
     }
     if (NightVision_Switch)
     {
         return;
     }
     CamNightVision = CurrentCamera.gameObject.AddComponent <CameraPlay_NightVision>() as CameraPlay_NightVision;
     if (CamNightVision.CamTurnOff)
     {
         return;
     }
     NightVision_Switch      = true;
     CamNightVision.Duration = 1;
     CamNightVision.Preset   = (CameraPlay_NightVision.NightVision_Preset)Preset;
 }
Exemple #2
0
 /// <summary>
 /// 夜视效果
 /// </summary>
 public void NightVision_ON(NightVision_Preset Preset, float time)
 {
     CameraPlay.NightVision_ON(Preset, time);
 }
    void Update()
    {
#if UNITY_EDITOR
        if (Application.isPlaying != true)
        {
            SCShader = Shader.Find("CameraPlay/NightVision");
        }
#endif

        if (PresetMemo != Preset)
        {
            PresetMemo = Preset;

            float[] P1 = new float[12] {
                0.757f, 0.098f, 0.458f, -2.49f, 0.559f, -0.298f, 1.202f, 0.515f, 1, 0, 0, 0
            };
            float[] P2 = new float[12] {
                0.2f, 0.202f, 0.68f, -1.49f, 0.084f, -0.019f, 2f, 0.166f, 1.948f, -0.1f, 0.15f, -0.07f
            };
            float[] P3 = new float[12] {
                1.45f, 0.01f, 0.112f, -0.07f, 0.111f, -0.077f, 0.071f, 0, 0.245f, 0, 0, 0
            };
            float[] P4 = new float[12] {
                0.779f, 0.185f, 0.706f, 1.21f, 0.24f, 0.138f, 2, 0.07f, 1.224f, -0.21f, -0.34f, 0
            };
            float[] P5 = new float[12] {
                0.2f, 0.028f, 0.706f, 1.21f, 0.397f, -0.24f, 2, 0.298f, 1.224f, -0.08f, 0.48f, -0.57f
            };
            float[] P6 = new float[12] {
                0.2f, 0.159f, 0.622f, -2.28f, 0.409f, -0.24f, 0.166f, 0.028f, 2, -0.08f, 0.22f, 0.57f
            };
            float[] P7 = new float[12] {
                2, 0.054f, 1, -2.28f, 0.409f, -1f, 2, 0.187f, 0.241f, 0, 1.58f, 0.21f
            };
            float[] P8 = new float[12] {
                2, 0.054f, 1, 1.28f, 0.409f, -1, 0.41f, 0.656f, 0.427f, 0.95f, -0.35f, 1.41f
            };
            float[] P9 = new float[12] {
                2, 0.281f, 0.156f, 1.85f, 0.709f, -1, 0.41f, 0.109f, 0.34f, 0.95f, 0.36f, -0.14f
            };
            float[] P10 = new float[12] {
                0.905f, 0.281f, 0.156f, 1.85f, 0.558f, -0.974f, 1.639f, 0.252f, 1.074f, 0.46f, 0.95f, 0.58f
            };

            float[] PR = new float[12];

            if (Preset == NightVision_Preset.Night_Vision_FX)
            {
                PR = P1;
            }
            if (Preset == NightVision_Preset.Night_Vision_Classic)
            {
                PR = P2;
            }
            if (Preset == NightVision_Preset.Night_Vision_Full)
            {
                PR = P3;
            }
            if (Preset == NightVision_Preset.Night_Vision_Dark)
            {
                PR = P4;
            }
            if (Preset == NightVision_Preset.Night_Vision_Sharp)
            {
                PR = P5;
            }
            if (Preset == NightVision_Preset.Night_Vision_BlueSky)
            {
                PR = P6;
            }
            if (Preset == NightVision_Preset.Night_Vision_Low_Light)
            {
                PR = P7;
            }
            if (Preset == NightVision_Preset.Night_Vision_Pinky)
            {
                PR = P8;
            }
            if (Preset == NightVision_Preset.Night_Vision_RedBurn)
            {
                PR = P9;
            }
            if (Preset == NightVision_Preset.Night_Vision_PurpleShadow)
            {
                PR = P10;
            }
            if (Preset != NightVision_Preset.Night_Vision_Personalized)
            {
                Greenness      = PR[0];
                Vignette       = PR[1];
                Vignette_Alpha = PR[2];
                Distortion     = PR[3];
                Noise          = PR[4];
                Intensity      = PR[5];
                Light          = PR[6];
                Light2         = PR[7];
                Line           = PR[8];
                Color_R        = PR[9];
                Color_G        = PR[10];
                Color_B        = PR[11];
            }
        }
        if (CamTurnOff == false)
        {
            Timer += Time.deltaTime * (1 / Duration);
            if (Timer > 1f)
            {
                Timer = 1;
            }
            flashy = Timer;
        }

        if (CamTurnOff)
        {
            Timer -= Time.deltaTime * (1 / Duration);
            flashy = Timer;
            if (Timer < 0)
            {
                CameraPlay.NightVision_Switch = false;
                Object.Destroy(this);
            }
        }
    }