Skip to content
This repository was archived by the owner on Feb 27, 2023. It is now read-only.

Commit 0807d49

Browse files
committed
Splitting string
1 parent d7e2bcd commit 0807d49

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

packages/unity-interface/UnityInterface.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,10 @@ export class UnityInterface implements IUnityInterface {
277277
}
278278

279279
public AddWearablesToCatalog(wearables: WearableV2[], context?: string) {
280-
const messageLimit = 1
281-
if (wearables.length > messageLimit) {
282-
const clone = wearables.slice()
283-
while (clone.length) {
284-
wearables = clone.splice(0, messageLimit)
285-
this.SendMessageToUnity('Main', 'AddWearablesToCatalog', JSON.stringify({ wearables, context }))
286-
}
287-
} else {
288-
this.SendMessageToUnity('Main', 'AddWearablesToCatalog', JSON.stringify({ wearables, context }))
280+
const jsonString = JSON.stringify({ wearables, context })
281+
const result = jsonString.match(/.{1,500000}/g) || []
282+
for(var i = 0;i<result.length;i++){
283+
this.SendMessageToUnity('Main', 'AddWearablesToCatalog', result[i])
289284
}
290285
}
291286

0 commit comments

Comments
 (0)