Hi, I started a new project, added some UI, and now wanted to add TAB key navigation since this feature has been missing from Unity for almost a decade now (lmao).
So I added a new script to the project and added it to a gameObject:
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class UI_TabKeyNavigation : MonoBehaviour
{
void Update()
{
if (Input.GetKeyDown(KeyCode.Tab))
{
GameObject c = EventSystem.current.currentSelectedGameObject;
if (c == null) { return; }
Selectable s = c.GetComponent<Selectable>();
if (s == null) { return; }
Selectable jump = Input.GetKey(KeyCode.LeftShift)
? s.FindSelectableOnUp() : s.FindSelectableOnDown();
if (jump != null) { jump.Select(); }
}
}
}
Enter PlayMode to test it…
All of a sudden my fans go on MAX.
Check CPU usage in Task Manager > its freaking 100%???
Wat is going on here Unity??
If Vsync is disabled, it means your computer is working as fast as it possibly can (100%) in order to render as many frames as possible for no good reason.
Enable Vsync and framerate is a steady 60 fps, disable it and it may be 600 or more, with only every tenth rendered image actually displayed.
For a build, vsync is enabled via Quality settings. It may still be overridden on the driver level however.
To be precise Vsync’s decrease of the CPU is a side effect of what’s actually happening: the GPU trying to make as many frames as possible. If the CPU is sufficiently powerful to keep the GPU fed with data turning it on can reduce the CPU load, but if the CPU is too weak to feed the GPU then it’s going to stay at 100%.
Your monitor is somewhat important here too as even budget displays often have a higher refresh rate (eg 144Hz) which means that the CPU has to work up to 2.4x as hard (60Hz = 16.67ms per frame, 144Hz = 6.94ms per frame).