SHA256
65 lines
2.1 KiB
C#
65 lines
2.1 KiB
C#
using ADOFAIRenderer.UI;
|
|
using UnityEngine;
|
|
|
|
namespace ADOFAIRenderer.Core;
|
|
|
|
[DefaultExecutionOrder(int.MinValue)]
|
|
internal class FirstUpdateHook : MonoBehaviour
|
|
{
|
|
private bool _checkedFFmpeg;
|
|
private bool _checkedNvidiaDriver;
|
|
|
|
private void Update()
|
|
{
|
|
if (!_checkedFFmpeg)
|
|
{
|
|
if (FFmpegDownloadUI.Instance) return;
|
|
|
|
if (!FFmpegDownloadUI.CheckFFmpegExists())
|
|
{
|
|
FFmpegDownloadUI.ShowDownloadUI();
|
|
return;
|
|
}
|
|
_checkedFFmpeg = true;
|
|
}
|
|
|
|
if (!_checkedNvidiaDriver)
|
|
{
|
|
if (CommonWarningDialogUI.Instance) return;
|
|
|
|
_checkedNvidiaDriver = true;
|
|
CheckNvidiaDriverWarning();
|
|
}
|
|
|
|
if (RenderManager.Instance)
|
|
{
|
|
RenderManager.Instance.OnPreUpdate();
|
|
}
|
|
}
|
|
|
|
private void CheckNvidiaDriverWarning()
|
|
{
|
|
var driverVer = Util.GPUUtil.GetNvidiaDriverVersion();
|
|
if (driverVer is null or >= 610.00f) return;
|
|
|
|
var currentVersion = driverVer.Value.ToString("F2");
|
|
|
|
CommonWarningDialogUI.ShowDialog(
|
|
"NVIDIA Graphics Driver Update Recommended",
|
|
$"Currently detected NVIDIA graphics driver version: <b><color=#ff5555>{currentVersion}</color></b>\n\nDriver version <b><color=#55ff55>610.00 or higher</color></b> is required to render video using hardware acceleration (NVENC).\n\nIf the driver version is lower, encoding may fail or fallback to software (CPU) encoding, significantly slowing down rendering. Please update your graphics driver.",
|
|
new DialogButton("Update Driver", () =>
|
|
{
|
|
Application.OpenURL("https://www.nvidia.com/Download/index.aspx");
|
|
Application.Quit();
|
|
}, new Color(0.0f, 0.8f, 1.0f, 1.0f)),
|
|
new DialogButton("Disable Feature", () =>
|
|
{
|
|
RenderMod.IsFeatureDisabled = true;
|
|
}),
|
|
new DialogButton("Continue Anyway", () =>
|
|
{
|
|
// ignored
|
|
})
|
|
);
|
|
}
|
|
} |