| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 | using UnityEngine;using System.Collections;using System.Collections.Generic;using TMPro;using UnityEngine.UI;using FXV.Internal;namespace FXV.FogDemo{    public class fxvDemo : MonoBehaviour    {        [SerializeField]        Image fadeInImage;        [SerializeField]        Text toggleText;        [SerializeField]        GameObject groupTypesRoot;        [SerializeField]        GameObject animationRoot;        [SerializeField]        Light mainLight;        [SerializeField]        Color fogColorLit = Color.white;        [SerializeField]        Color fogColorUnlit = Color.white;        [SerializeField]        GameObject[] cameraObjects;        int currentType = 0;        float fadeT = 1.0f;        bool affectedByLights = true;        void Start()        {            if (toggleText)            {                toggleText.gameObject.SetActive(false);            }            if (fadeInImage)            {                fadeInImage.gameObject.SetActive(true);                fadeInImage.color = Color.black;                fadeT = 1.5f;            }            else            {                fadeT = 0.0f;            }            if (animationRoot && groupTypesRoot)            {                for (int i = 0; i < groupTypesRoot.transform.childCount; i++)                {                    fxvFogPresentation fogPres = groupTypesRoot.transform.GetChild(i).GetComponent<fxvFogPresentation>();                    fogPres.SetLightsFade(0.0f, false);                }            }        }        public void SetActionTex(string text)        {            if (toggleText)            {                if (text != null)                {                    toggleText.gameObject.SetActive(true);                    toggleText.text = text;                }                else                {                    toggleText.gameObject.SetActive(false);                }            }        }        void Update()        {            if (fadeT > 0.0f)            {                fadeT -= Time.deltaTime;                if (fadeT <= 0.0f)                {                    fadeT = 0.0f;                    fadeInImage.gameObject.SetActive(false);                }                Color c = Color.black;                c.a = fadeT;                fadeInImage.color = c;            }            if (animationRoot)            {                if (fadeT == 0.0f)                {                    Animator anim = animationRoot.GetComponentInChildren<Animator>();                    if (!anim.enabled)                    {                        anim.enabled = true;                        groupTypesRoot.transform.GetChild(0).GetComponent<fxvFogPresentation>().SetLightsFade(1.0f, 1.5f);                    }                    if (Input.GetKeyDown(KeyCode.RightArrow) || anim.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1.0f)                    {                        NextType();                    }                    if (Input.GetKeyDown(KeyCode.Space))                    {                        SwitchLights();                    }                }            }            if (cameraObjects != null && cameraObjects.Length > 1)            {                if (Input.GetKeyDown(KeyCode.C))                {                    for (int i = 0;i < cameraObjects.Length; ++i)                    {                        cameraObjects[i].SetActive(!cameraObjects[i].activeSelf);                    }                }            }        }        public void SwitchLights()        {            if (groupTypesRoot)            {                affectedByLights = !affectedByLights;                if (mainLight)                {                    mainLight.intensity = affectedByLights ? 0.1f : 0.6f;                }                for (int i = 0; i < groupTypesRoot.transform.childCount; i++)                {                    fxvFogPresentation fogPres = groupTypesRoot.transform.GetChild(i).GetComponent<fxvFogPresentation>();                    fogPres.SetAffectedByLights(affectedByLights);                    fogPres.SetFogColor(affectedByLights ? fogColorLit : fogColorUnlit);                }            }        }        public void NextType()        {            if (groupTypesRoot)            {                currentType++;                if (currentType >= groupTypesRoot.transform.childCount)                {                    currentType = 0;                }                animationRoot.transform.position = groupTypesRoot.transform.GetChild(currentType).position;                animationRoot.GetComponentInChildren<Animator>().Play("CameraShowcase", -1, 0.0f);                for (int i = 0; i < groupTypesRoot.transform.childCount; i++)                {                    fxvFogPresentation fogPres = groupTypesRoot.transform.GetChild(i).GetComponent<fxvFogPresentation>();                    if (i == currentType)                    {                        fogPres.SetLightsFade(1.0f, 1.5f);                    }                    else                    {                        fogPres.SetLightsFade(0.0f);                    }                }            }        }    }}
 |