Skip to content

Commit 04ae1f3

Browse files
Refactor UnityContext type declaration to include sendMessage method for invoking public methods on Unity instances
1 parent de54e23 commit 04ae1f3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

module/source/types/unity-context.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { UnityEventParameter } from "./unity-event-parameters";
12
import { UnityInstance } from "./unity-instance";
23
import { UnityProvider } from "./unity-provider";
34

@@ -40,6 +41,18 @@ type UnityContext = {
4041
*/
4142
readonly requestPointerLock: VoidFunction;
4243

44+
/**
45+
* Sends a message to the UnityInstance to invoke a public method.
46+
* @param gameObjectName the name of the game object in your Unity scene.
47+
* @param methodName the name of the public method on the game object.
48+
* @param parameter an optional parameter to pass along to the method.
49+
*/
50+
readonly sendMessage: (
51+
gameObjectName: string,
52+
methodName: string,
53+
parameter?: UnityEventParameter
54+
) => void;
55+
4356
/**
4457
* An unsafe reference to the Unity Instance.
4558
* This reference should be used with caution, as it may not be available

0 commit comments

Comments
 (0)