Skip to content

Commit 4266ed1

Browse files
committed
Fix handle deprecation of unity WebGL variables
1 parent 770b216 commit 4266ed1

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

Assets/Plugins/WebGL/WebGlPlugins.jslib

+32-5
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22
var WebGlPlugins =
33
{
44
_LogStartTime: function (str) {
5-
var startTimeText = Pointer_stringify(str);
5+
var startTimeText = "Missing function";
66

7+
if(typeof UTF8ToString != 'undefined') {
8+
startTimeText = UTF8ToString(str);
9+
}
10+
else if (typeof Pointer_stringify !== 'undefined') {
11+
startTimeText = Pointer_stringify(str);
12+
}
13+
714
if(typeof unityLoadingFinished !== 'undefined') {
815
unityLoadingFinished(startTimeText);
916
}
@@ -14,22 +21,42 @@ var WebGlPlugins =
1421

1522
_GetTotalMemorySize: function()
1623
{
17-
return TOTAL_MEMORY;
24+
if(typeof TOTAL_MEMORY !== 'undefined') {
25+
return TOTAL_MEMORY;
26+
}
27+
28+
console.warn('Problem with retrieving unity value. TOTAL_MEMORY: ' + typeof TOTAL_MEMORY);
29+
return -1;
1830
},
1931

2032
_GetTotalStackSize: function()
2133
{
22-
return TOTAL_STACK;
34+
if(typeof TOTAL_STACK !== 'undefined') {
35+
return TOTAL_STACK;
36+
}
37+
38+
console.warn('Problem with retrieving unity value. TOTAL_STACK: ' + typeof TOTAL_STACK);
39+
return -1;
2340
},
2441

2542
_GetStaticMemorySize: function()
2643
{
27-
return STATICTOP - STATIC_BASE;
44+
if(typeof STATICTOP !== 'undefined' && typeof STATIC_BASE !== 'undefined') {
45+
return STATICTOP - STATIC_BASE;
46+
}
47+
48+
console.warn('Problem with retrieving unity value. STATICTOP: ' + typeof STATICTOP + ', STATIC_BASE: ' + typeof STATIC_BASE);
49+
return -1;
2850
},
2951

3052
_GetDynamicMemorySize: function()
3153
{
32-
return HEAP32[DYNAMICTOP_PTR >> 2] - DYNAMIC_BASE;
54+
if(typeof HEAP32 !== 'undefined' && typeof DYNAMICTOP_PTR !== 'undefined' && typeof DYNAMIC_BASE !== 'undefined') {
55+
return HEAP32[DYNAMICTOP_PTR >> 2] - DYNAMIC_BASE;
56+
}
57+
58+
console.warn('Problem with retrieving unity value. HEAP32: ' + HEAP32 + ', DYNAMICTOP_PTR: ' + DYNAMICTOP_PTR + ', DYNAMIC_BASE: ' + DYNAMIC_BASE);
59+
return -1;
3360
}
3461
};
3562

0 commit comments

Comments
 (0)