Is here something to do with this script. It lags very much and drops over 30 frames.
It is day and night script what calculates time, moves sun etc.
#pragma strict
public var Sun : Light;
var stars : GameObject;
public var secondsInFullDay : float = 120f;
public var currentTimeOfDay : float;
public var timeMultiplier : float = 1f;
var sunInitialIntensity : float;
function Start () {
sunInitialIntensity = Sun.intensity;
}
function Update () {
UpdateSun();
currentTimeOfDay += (Time.deltaTime / secondsInFullDay) * timeMultiplier;
if (currentTimeOfDay >= 1) {
currentTimeOfDay = 0;
}
}
function UpdateSun(){
Sun.transform.localRotation = Quaternion.Euler((currentTimeOfDay * 360f) - 90, 170, 0);
var intensityMultiplier : float = 1;
if (currentTimeOfDay <= 0.23f || currentTimeOfDay >= 0.75f) {
intensityMultiplier = 0;
}
else if (currentTimeOfDay <= 0.25f) {
intensityMultiplier = Mathf.Clamp01((currentTimeOfDay - 0.23f) * (1 / 0.02f));
}
else if (currentTimeOfDay >= 0.73f) {
intensityMultiplier = Mathf.Clamp01(1 - ((currentTimeOfDay - 0.73f) * (1 / 0.02f)));
}
if(currentTimeOfDay < 0.197636){
stars.SetActive(true);
}
if(currentTimeOfDay > 0.197636 && currentTimeOfDay < 0.7762121){
stars.SetActive(false);
}
if(currentTimeOfDay > 0.7762121){
stars.SetActive(true);
}
Sun.intensity = sunInitialIntensity * intensityMultiplier;
}
↧