Skip to content

Commit b1b7fc6

Browse files
feat: add getMetricsInfo method to retrieve performance metrics from Unity instance
1 parent 6645575 commit b1b7fc6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

module/source/hooks/use-unity-context.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ const useUnityContext = (unityConfig: UnityConfig): UnityContext => {
100100
[unityInstance]
101101
);
102102

103+
/**
104+
* Gets the metrics information from the Unity Instance.
105+
* This includes performance metrics such as FPS, memory usage, etc.
106+
* @returns A function that returns the metrics information.
107+
*/
108+
const getMetricsInfo = useCallback(
109+
() => unityInstance?.GetMetricsInfo?.(),
110+
[unityInstance]
111+
);
112+
103113
// Initialize the UnityProvider with the provided configuration
104114
// This is where you would typically load the Unity instance
105115
// and set up event listeners, etc.
@@ -113,6 +123,7 @@ const useUnityContext = (unityConfig: UnityConfig): UnityContext => {
113123
sendMessage,
114124
takeScreenshot,
115125
unload,
126+
getMetricsInfo,
116127
addEventListener: eventSystem.addEventListener,
117128
removeEventListener: eventSystem.removeEventListener,
118129
UNSAFE__unityInstance: unityInstance,

0 commit comments

Comments
 (0)