wip : shader prewarm & fps control
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Collections;
|
||||
using OctoCore.Navigation.Data;
|
||||
using OctoCore.UI;
|
||||
using UnityEngine;
|
||||
@@ -20,10 +21,14 @@ namespace OctoCore.Navigation
|
||||
[Header("UI Settings")]
|
||||
[SerializeField, Tooltip("Optional panel to show/hide (options, credits...)")]
|
||||
private GameObject _optionalPanel;
|
||||
[SerializeField] private GameObject _loadingScreen;
|
||||
[SerializeField] private GameObject _loadingWheel;
|
||||
|
||||
[SerializeField] private Button _optionalPanelFirstButton;
|
||||
[SerializeField] private Button _mainPanelDefaultButton;
|
||||
|
||||
private bool _isLoading = false;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
// Hide optional panel on start if assigned
|
||||
@@ -35,6 +40,12 @@ namespace OctoCore.Navigation
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (_isLoading && _loadingWheel)
|
||||
_loadingWheel.transform.Rotate(0, 0, -200f * Time.deltaTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load the first scene. Called by the Play button.
|
||||
/// </summary>
|
||||
@@ -52,6 +63,21 @@ namespace OctoCore.Navigation
|
||||
return;
|
||||
}
|
||||
|
||||
_ = PlayRoutine();
|
||||
}
|
||||
|
||||
private async Awaitable PlayRoutine()
|
||||
{
|
||||
_isLoading = true;
|
||||
|
||||
if (_loadingScreen) _loadingScreen.SetActive(true);
|
||||
|
||||
await System.Threading.Tasks.Task.Delay(5000);
|
||||
#if !UNITY_EDITOR
|
||||
Shader.WarmupAllShaders();
|
||||
#endif
|
||||
|
||||
_isLoading = false;
|
||||
OctoCore.Instance.Navigation.LoadScene(_firstSceneData);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user