| | 1 | | using System; |
| | 2 | | using System.Collections; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using UnityEngine; |
| | 5 | |
|
| | 6 | | public class InfFloorBlenderControl : MonoBehaviour |
| | 7 | | { |
| | 8 | | [Header("Skybox Data")] |
| | 9 | | [SerializeField] private Material skyboxMaterial; |
| | 10 | |
|
| | 11 | | [Header("Infinite Floor Blender Data")] |
| | 12 | | [SerializeField] private Material infFloorBlenderMaterial; |
| | 13 | |
|
| | 14 | | [Space] |
| | 15 | | [Header("Colors Procedural Skybox ")] |
| | 16 | | [SerializeField] private Color _proceduralSkyboxGroundColor; |
| | 17 | | [SerializeField] private Color _proceduralSkyboxHorizonColor; |
| | 18 | |
|
| | 19 | | [Space] |
| | 20 | | [Header("Time Interval")] |
| | 21 | | [Tooltip("Time interval dictates the amount of time script will wait before changing the colors")] |
| | 22 | |
|
| | 23 | | [SerializeField] private bool _isTimeIntervalEnabled; |
| 0 | 24 | | [SerializeField] private float _timeInterval = 5f; |
| | 25 | |
|
| | 26 | | [Header("Debug")] |
| | 27 | | [SerializeField] private bool _isDebug; |
| | 28 | |
|
| | 29 | | // Start is called before the first frame update |
| | 30 | |
|
| | 31 | | private void Awake() |
| | 32 | | { |
| | 33 | |
|
| 0 | 34 | | } |
| | 35 | | void Start() |
| | 36 | | { |
| 0 | 37 | | GetProceduralSkyboxColors(); |
| 0 | 38 | | SetProceduralInfBlenderColors(); |
| 0 | 39 | | } |
| | 40 | |
|
| | 41 | | // Update is called once per frame |
| | 42 | | void Update() |
| | 43 | | { |
| | 44 | | // example |
| 0 | 45 | | if (_isTimeIntervalEnabled == true) |
| | 46 | | { |
| | 47 | | // every 5 seconds change the colors |
| 0 | 48 | | Invoke("GetProceduralSkyboxColors" , _timeInterval); |
| 0 | 49 | | Invoke("SetProceduralInfBlenderColors" , _timeInterval); |
| | 50 | | } |
| 0 | 51 | | } |
| | 52 | |
|
| | 53 | | // get _proceduralSkyboxGroundColor and _proceduralSkyboxHorizonColor from skybox material |
| | 54 | | private void GetProceduralSkyboxColors() |
| | 55 | | { |
| 0 | 56 | | _proceduralSkyboxGroundColor = skyboxMaterial.GetColor("_groundColor"); |
| 0 | 57 | | _proceduralSkyboxHorizonColor = skyboxMaterial.GetColor("_horizonColor"); |
| | 58 | |
|
| 0 | 59 | | if (_isDebug == true) |
| | 60 | | { |
| 0 | 61 | | Debug.Log("Getting Procedural Colors from Skybox"); |
| | 62 | | } |
| 0 | 63 | | } |
| | 64 | |
|
| | 65 | | // set _proceduralSkyboxGroundColor and _proceduralSkyboxHorizonColor to infFloorBlenderMaterial |
| | 66 | | private void SetProceduralInfBlenderColors() |
| | 67 | | { |
| 0 | 68 | | infFloorBlenderMaterial.SetColor("_ColorSky", _proceduralSkyboxHorizonColor); |
| 0 | 69 | | infFloorBlenderMaterial.SetColor("_ColorFloor", _proceduralSkyboxGroundColor); |
| | 70 | |
|
| 0 | 71 | | if (_isDebug == true) |
| | 72 | | { |
| 0 | 73 | | Debug.Log("Setting Procedural Colors to InfFloorBlender"); |
| | 74 | | } |
| 0 | 75 | | } |
| | 76 | |
|
| | 77 | | } |