@@ -56,21 +56,31 @@ var exportDLL = {
5656 var _getTempRet0 = ( ) => __tempRet0 | 0
5757 }
5858
59- if ( typeof addFunction === "undefined" ) {
60- const table = Module . wasmTable || wasmTable // whichever Unity exposes
61- var addFunction = function ( jsFunc /*, sig */ ) {
62- const idx = table . length
63- table . grow ( 1 )
64- table . set ( idx , jsFunc )
65- return idx
66- }
67- }
68- if ( typeof removeFunction === "undefined" ) {
69- const table = Module . wasmTable || wasmTable
70- var removeFunction = function ( idx ) {
71- // Emscripten no longer shrinks the table – just replace entry with a noop
72- table . set ( idx , ( ) => { } )
73- }
59+ // Unity 6.3+ compatibility: helper to get wasmTable from multiple sources
60+ var getWasmTable = function ( ) {
61+ if ( typeof wasmTable !== 'undefined' ) return wasmTable ;
62+ if ( Module && Module . wasmTable ) return Module . wasmTable ;
63+ if ( Module && Module . asm && Module . asm . __indirect_function_table ) return Module . asm . __indirect_function_table ;
64+ return null ;
65+ } ;
66+
67+ if ( typeof addFunction === "undefined" ) {
68+ var addFunction = function ( jsFunc /*, sig */ ) {
69+ const table = getWasmTable ( ) ;
70+ if ( ! table ) throw new Error ( 'wasmTable not found for addFunction' ) ;
71+ const idx = table . length ;
72+ table . grow ( 1 ) ;
73+ table . set ( idx , jsFunc ) ;
74+ return idx ;
75+ }
76+ }
77+ if ( typeof removeFunction === "undefined" ) {
78+ var removeFunction = function ( idx ) {
79+ const table = getWasmTable ( ) ;
80+ if ( ! table ) return ; // silently fail if no table
81+ // Emscripten no longer shrinks the table – just replace entry with a noop
82+ table . set ( idx , ( ) => { } ) ;
83+ }
7484 }
7585
7686 let oldUpdateGlobalBufferAndViews = updateGlobalBufferAndViews ;
@@ -85,6 +95,21 @@ var exportDLL = {
8595 ) ;
8696 }
8797
98+ // Unity 6.3+ may call updateMemoryViews directly instead of updateGlobalBufferAndViews
99+ if ( typeof updateMemoryViews === "function" ) {
100+ let oldUpdateMemoryViews = updateMemoryViews ;
101+ updateMemoryViews = function ( buf ) {
102+ oldUpdateMemoryViews ( buf ) ;
103+ global . PuertsWebGL . updateGlobalBufferAndViews (
104+ HEAP8 ,
105+ HEAPU8 ,
106+ HEAP32 ,
107+ HEAPF32 ,
108+ HEAPF64
109+ ) ;
110+ }
111+ }
112+
88113 global . PuertsWebGL . Init ( {
89114 UTF8ToString,
90115 UTF16ToString,
@@ -99,7 +124,11 @@ var exportDLL = {
99124 stackSave,
100125 stackRestore,
101126 getWasmTableEntry : ( typeof getWasmTableEntry != 'undefined' ) ? getWasmTableEntry : function ( funcPtr ) {
102- return wasmTable . get ( funcPtr ) ;
127+ var table = getWasmTable ( ) ;
128+ if ( table ) {
129+ return table . get ( funcPtr ) ;
130+ }
131+ throw new Error ( 'wasmTable not found - Unity 6.3 may require WebAssembly.Table to be disabled in Player Settings' ) ;
103132 } ,
104133 addFunction,
105134 removeFunction,
0 commit comments