I have this script( i whant when it happends like 15 seconds the enum type switch to cloudy and in cloudy when its happend 10 seconds switchs to sunny )
I want that loop to repeat all the time.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CloudSystem : MonoBehaviour
{
public enum SkyType {Sunny,Cloudy};
public SkyType skyType;
public float changeSpeed = 0.01f;
private float cutOff;
public Material cloudMaterial;
private void Start()
{
cloudMaterial.SetFloat("_CutOff", 0); //Sets the cloudMaterial CutOff to 0 in the Start;
cutOff = cloudMaterial.GetFloat("_CutOff"); //Get the CutOff value to cutOff
}
void Update()
{
//Can Switch between Skys
switch (skyType)
{
case SkyType.Cloudy:
Cloudy();
break;
case SkyType.Sunny:
Sunny();
break;
}
}
void Cloudy()
{
cutOff = Mathf.MoveTowards(cutOff, 0.35f, changeSpeed * Time.deltaTime);
cloudMaterial.SetFloat("_CutOff", cutOff);
}
void Sunny()
{
cutOff = Mathf.MoveTowards(cutOff, 0, changeSpeed * Time.deltaTime);
cloudMaterial.SetFloat("_CutOff", cutOff);
}
}