首次提交
This commit is contained in:
97
Assets/Scripts/Demo/SceneSettings.cs
Normal file
97
Assets/Scripts/Demo/SceneSettings.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
using Enviro;
|
||||
using NBF;
|
||||
using UnityEngine;
|
||||
using WaveHarmonic.Crest;
|
||||
|
||||
public class SceneSettings : MonoBehaviour
|
||||
{
|
||||
public static SceneSettings Instance;
|
||||
|
||||
public int sceneID;
|
||||
|
||||
public string sceneName = "";
|
||||
|
||||
public Transform WaterObject;
|
||||
|
||||
public Transform Node;
|
||||
|
||||
public Transform GearNode;
|
||||
|
||||
public WaterRenderer Water;
|
||||
|
||||
// public ObiUpdater obiFixedUpdater;
|
||||
|
||||
public LineRenderer LineRenderer;
|
||||
|
||||
|
||||
public int FPS;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
if (Node == null)
|
||||
{
|
||||
Node = transform;
|
||||
}
|
||||
|
||||
if (GearNode == null)
|
||||
{
|
||||
GearNode = Node;
|
||||
}
|
||||
|
||||
// obiFixedUpdater = FindFirstObjectByType<ObiLateFixedUpdater>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
EnviroManager.instance.Time.Settings.simulate = true;
|
||||
// EnviroManager.instance.Time.SetTimeOfDay(0.5f * 24f);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
UpdateFPS();
|
||||
UpdateTimeOfDay();
|
||||
}
|
||||
|
||||
|
||||
#region FPS
|
||||
|
||||
public float updateInterval = 0.2f; // 更新间隔(秒)
|
||||
|
||||
private float accum = 0;
|
||||
private int frames = 0;
|
||||
private float timeleft;
|
||||
|
||||
void UpdateFPS()
|
||||
{
|
||||
timeleft -= Time.deltaTime;
|
||||
accum += Time.timeScale / Time.deltaTime;
|
||||
frames++;
|
||||
|
||||
if (timeleft <= 0.0f)
|
||||
{
|
||||
FPS = (int)(accum / frames);
|
||||
|
||||
timeleft = updateInterval;
|
||||
accum = 0.0f;
|
||||
frames = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 场景时间
|
||||
|
||||
private void UpdateTimeOfDay()
|
||||
{
|
||||
var p = GameTimer.GetGameDayProgress();
|
||||
// p = 0;
|
||||
// Debug.Log(p);
|
||||
EnviroManager.instance.Time.SetTimeOfDay(p * 24f);
|
||||
// if(AzureCoreSystem)
|
||||
// AzureCoreSystem.timeSystem.timeline = 24F * p;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user