ialex32x / unity-jsb

It brings Javascript runtime capability to Unity3D by integrating QuickJS.
MIT License
335 stars 41 forks source link

How to use UnityEngine without ReflectBind Mode? #115

Open mikejurka opened 1 year ago

mikejurka commented 1 year ago

I'm having trouble with my scripts not finding the UnityEngine module when I do a WebGL build. I have the same issue in-editor when I uncheck the ReflectBind mode.

Repro steps:

  1. JS Bridge > Generate Bindings and Type Definition
  2. Open Assets/Examples/Scenes/SampleScene.unity
  3. For Entry File name, select game_demo or example_monobehaviour
  4. Disable ReflectBind mode
  5. Press play

Expected: the examples run normally Actual: They don't run and in the console I see:

[JS] undefined:undefined module can not be resolved (UnityEngine)
    at require (native)
    at <anonymous> (assets/js-scripts/components/mikesample_mutate_global.js.bytes:10)
    at require (native)
    at <eval> (/Users/mike/code/unity-jsb/Scripts/src/components/mikesample_mutate_global.ts)

UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
QuickJS.Extra.MiniConsole:LogError (string) (at Assets/jsb-extra/MiniConsole/MiniConsole.cs:87)
QuickJS.Extra.MiniConsole:LogErrorFormat (string,object[]) (at Assets/jsb-extra/MiniConsole/MiniConsole.cs:160)
QuickJS.Extra.MiniConsole:UnityEngine.ILogHandler.LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[]) (at Assets/jsb-extra/MiniConsole/MiniConsole.cs:214)
UnityEngine.Debug:LogError (object)
QuickJS.Unity.JSBehaviour:CreateScriptInstance () (at Packages/cc.starlessnight.unity-jsb/Source/Unity/JSBehaviour.cs:669)
QuickJS.Unity.JSBehaviour:Awake () (at Packages/cc.starlessnight.unity-jsb/Source/Unity/JSBehaviour.cs:545)
ialex32x commented 1 year ago

I checked on unity2020.3+windows build. It works properly with these steps. Will this issue be reproduced on platform builds other than WebGL on your side?