Skip to content

Commit 9ef27a2

Browse files
Updated docs from Pointer_stringify to modern UTF8ToString method to reflect modern builds
1 parent 631c980 commit 9ef27a2

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed

documentation/docs/api/event-system.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,7 @@ The name of this file is irrelevant, but it must be placed in the `/Plugins/WebG
215215
```js showLineNumbers title="React.jslib"
216216
mergeInto(LibraryManager.library, {
217217
GameOver: function (userName, score) {
218-
window.dispatchReactUnityEvent(
219-
"GameOver",
220-
Pointer_stringify(userName),
221-
score
222-
);
218+
window.dispatchReactUnityEvent("GameOver", UTF8ToString(userName), score);
223219
},
224220
});
225221
```

documentation/docs/main-concepts/data-conversion.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ To return a string value you need to call \_malloc to allocate some memory and t
66

77
For arrays of primitive types, emscripten provides different ArrayBufferViews into it’s heap for different sizes of integer, unsigned integer or floating point representations of memory: HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64. To access a texture in WebGL, emscripten provides the GL.textures array which maps native texture IDs from Unity to WebGL texture objects. WebGL functions can be called on emscripten’s WebGL context, GLctx.
88

9-
A basic implementation could look something like this. In this example a series of methods is merged into the Unity library making this methods availble in CSharp. Each of these methods contain an example on how to handle specific types of data. No worries, the methods used for the conversion such as "Pointer_stringify" and "HEAPF32" are available natively.
9+
A basic implementation could look something like this. In this example a series of methods is merged into the Unity library making this methods availble in CSharp. Each of these methods contain an example on how to handle specific types of data. No worries, the methods used for the conversion such as "UTF8ToString" and "HEAPF32" are available natively.
1010

1111
```js showLineNumbers title="Example: Converting Data Types"
1212
mergeInto(LibraryManager.library, {
@@ -19,7 +19,7 @@ mergeInto(LibraryManager.library, {
1919
ShowPopup: function (textStringPointer) {
2020
window.dispatchReactUnityEvent(
2121
"ShowPopup",
22-
Pointer_stringify(textStringPointer)
22+
UTF8ToString(textStringPointer)
2323
);
2424
},
2525
SubmitScores: function (scoresFloatArrayPointer, arraySize) {

documentation/versioned_docs/version-8.x.x/api/communication-from-unity-to-react.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,13 @@ function App() {
6161

6262
To emit the Event Listener we've just created, we'll have to create a new JSLib file within our Unity Project first. This JSLib file will be places within the "Assets/Plugins/WebGL" directory. The JSLib itself has nothing to do with this module, it is natively supported by Unity and is used for all communication between your CSharp and JavaScript in any given context.
6363

64-
We'll start of by creating a new method inside of our JSLib. The name of this method can be anything, but in this example we'll give it it the same name as our Event Name to keep things clean. In the body of the method, we'll emit our Event Listener by invoking the global method "dispatchReactUnityEvent" exposed by this module. All of your Event Listeners are available using the Event Name as the first parameter. We'll pass along the userName and the score. The userName has to go through the built-in "Pointer_stringify" method in order to get the value, otherwise a int pointer will be passed instead. You can read more about parameters and [JavaScript to Unityscript types](#javascript-to-unityscript-types) here.
64+
We'll start of by creating a new method inside of our JSLib. The name of this method can be anything, but in this example we'll give it it the same name as our Event Name to keep things clean. In the body of the method, we'll emit our Event Listener by invoking the global method "dispatchReactUnityEvent" exposed by this module. All of your Event Listeners are available using the Event Name as the first parameter. We'll pass along the userName and the score. The userName has to go through the built-in `UTF8ToString` method (or the `Pointer_stringify` method when using Unity 2021.1 or older) in order to get the value, otherwise a int pointer will be passed instead. You can read more about parameters and [JavaScript to Unityscript types](#javascript-to-unityscript-types) here.
6565

6666
```js showLineNumber
6767
// File: MyPlugin.jslib
6868
mergeInto(LibraryManager.library, {
6969
GameOver: function (userName, score) {
70-
window.dispatchReactUnityEvent(
71-
"GameOver",
72-
Pointer_stringify(userName),
73-
score
74-
);
70+
window.dispatchReactUnityEvent("GameOver", UTF8ToString(userName), score);
7571
},
7672
});
7773
```

documentation/versioned_docs/version-8.x.x/concepts/javascript-to-unityscript-types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ For arrays of primitive types, emscripten provides different ArrayBufferViews in
88

99
#### Example implementation
1010

11-
A basic implementation could look something like this. In this example a series of methods is merged into the Unity library making this methods availble in CSharp. Each of these methods contain an example on how to handle specific types of data. No worries, the methods used for the conversion such as "Pointer_stringify" and "HEAPF32" are available natively.
11+
A basic implementation could look something like this. In this example a series of methods is merged into the Unity library making this methods availble in CSharp. Each of these methods contain an example on how to handle specific types of data. No worries, the methods used for the conversion such as "UTF8ToString" and "HEAPF32" are available natively.
1212

1313
```js showLineNumbers
1414
mergeInto(LibraryManager.library, {
@@ -21,7 +21,7 @@ mergeInto(LibraryManager.library, {
2121
ShowPopup: function (textStringPointer) {
2222
window.dispatchReactUnityEvent(
2323
"ShowPopup",
24-
Pointer_stringify(textStringPointer)
24+
UTF8ToString(textStringPointer)
2525
);
2626
},
2727
SubmitScores: function (scoresFloatArrayPointer, arraySize) {

0 commit comments

Comments
 (0)