Hello guys im trying to convert a js script to c# script,but im getting four errors in the lines(29,58,71,73).This script is used for simple day night cycle of a skybox…Any help will be much appreciated
Thank You ![]()
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Sky : MonoBehaviour {
public float secondsPerMinute = 0.625f;
public float startTime = 12.0f;
public float latitudeAngle = 45.0f;
public Transform sunTilt;
private float day = 1;
private float min = 0;
private float textOffset;
private Material skyMat;
private Transform sunOrbit;
public float smoothMin;
public float roughSun;
void Start()
{
skyMat = GetComponent<Renderer>().sharedMaterial;
sunOrbit = sunTilt.GetChild(0);
sunTilt.eulerAngles.x = Mathf.Clamp(latitudeAngle, 0, 90);
TimeLoop(startTime);
if (secondsPerMinute < 0.0167f)
{
secondsPerMinute = 0.0166666f;
}
}
IEnumerator TimeLoop(float t)
{
min = Mathf.Floor(t * 60);
while (true)
{
while (min < 1440)
{
yield return new WaitForSeconds(secondsPerMinute);
min += 1;
}
day += 1;
min = 0;
}
}
void UpdateSkyOld()
{
textOffset = Mathf.Cos((((min) / 1440) * 2) * Mathf.PI)80.25f + 0.25f;
skyMat.mainTextureOffset = new Vector2(textOffset, 0);
roughSun = min;
}
void UpdateSky()
{
smoothMin = (Time.time / secondsPerMinute) + (startTime * 60);
smoothMin = smoothMin - (Mathf.Floor(smoothMin / 1440) * 1440);
sunOrbit.localEulerAngles.y = smoothMin / 4;
textOffset = Mathf.Cos((((smoothMin) / 1440) * 2) * Mathf.PI) * 0.25f + 0.25f;
skyMat.mainTextureOffset = new vector2(Mathf.Round((textOffset - (Mathf.Floor(textOffset / 360) * 360)) * 1000) / 1000, 0);
}
void Update()
{
UpdateSky();
}
}