I’m trying to create a script for a day/night cycle and It’s gone well so far, but I’m facing a bit of a problem.
This is where the error brought me to:
private void BlendSkybox() {
float temp = 0;
switch(_tod) {
case TimeOfDay.SunRise:
temp = (_timeOfDay - sunRise) / _dayCycleInSeconds * skyboxBlendModifier;
break;
case TimeOfDay.SunSet:
temp = (_timeOfDay - sunset) / _dayCycleInSeconds * skyboxBlendModifier;
temp = 1 - temp;
break;
}
RenderSettings.skybox.SetFloat("_Blend",0);
Debug.Log(temp);
}
}
If I could get some help with this that would be much appreciated 
Can you post the source file in its entirety?
using UnityEngine;
using System.Collections;
public class GameTime : MonoBehaviour {
public enum TimeOfDay {
Idle,
SunRise,
SunSet,
}
public Transform[] sun;
public float dayCycleInMinutes = 1;
public float sunRise;
public float sunSet;
public float skyboxBlendModifier;
private Sun[] _sunScript;
private float _degreeRotation;
private float _timeOfDay;
private float _dayCycleInSeconds;
private const float SECOND = 1;
private const float MINUTE = 60 * SECOND;
private const float HOUR = 60 * MINUTE;
private const float DAY = 24 * HOUR;
private const float DEGREES_PER_SECOND = 360 / DAY;
private TimeOfDay _tod;
// Use this for initialization
void Start () {
_tod = TimeOfDay.Idle;
_dayCycleInSeconds = dayCycleInMinutes * MINUTE;
RenderSettings.skybox.SetFloat("_Blend",0);
_sunScript = new Sun[sun.Length];
for(int cnt = 0; cnt < sun.Length; cnt++) {
Sun temp =sun[cnt].GetComponent<Sun>();
if(temp ==null) {
Debug.LogWarning("Sun script not found. Adding it.");
sun[cnt].gameObject.AddComponent<Sun>();
temp =sun[cnt].GetComponent<Sun>();
}
_sunScript[cnt] =temp;
}
_timeOfDay= 0;
_degreeRotation = DEGREES_PER_SECOND * DAY / (_dayCycleInSeconds);
sunRise *= _dayCycleInSeconds;
sunSet *= _dayCycleInSeconds;
}
// Update is called once per frame
void Update () {
for(int cnt = 0; cnt < sun.Length; cnt++) {
sun[cnt].Rotate(new Vector3(_degreeRotation, 0, 0) * Time.deltaTime);
_timeOfDay += Time.deltaTime;
Debug.Log(_timeOfDay);
if(_timeOfDay > sunRise) {
_tod = GameTime.TimeOfDay.SunRise;
Blendskybox();
}
}
private void BlendSkybox() {
float temp = 0;
switch(_tod) {
case TimeOfDay.SunRise:
temp = (_timeOfDay - sunRise) / _dayCycleInSeconds * skyboxBlendModifier;
break;
case TimeOfDay.SunSet:
temp = (_timeOfDay - sunset) / _dayCycleInSeconds * skyboxBlendModifier;
temp = 1 - temp;
break;
}
RenderSettings.skybox.SetFloat("_Blend",0);
Debug.Log(temp);
}
}
like this? xD
It looks like you might be missing a closing bracket, but it’s a little hard to tell due to the formatting.
Yeah, you’re missing a closing curly brace on your Update method:
void Update ()
{
for(int cnt = 0; cnt < sun.Length; cnt++)
{
sun[cnt].Rotate(new Vector3(_degreeRotation, 0, 0) * Time.deltaTime);
_timeOfDay += Time.deltaTime;
Debug.Log(_timeOfDay);
if(_timeOfDay > sunRise)
{
_tod = GameTime.TimeOfDay.SunRise;
Blendskybox();
}
}
Ok, thanks for the help, I’ll see what I can do 