Open lorenalexm opened 3 years ago
The Update
call was moved into another MonoBehaviour JSBehaviourFull
(I'm finding a better way to friendly switch between JSBehaviour and JSBehaviourFull (You can not change one into another in Unity Editor at present). Anyway, I'll check it in my environment.
Changing over to the JSBehaviourFull
component does seem to resolve the issue with the Update
method being called, so that is wonderful. Thank you!
It does seem in moving to the new component that I am having an error thrown when ending the "Play session" within the editor. It is showing a script runtime not ready error once wrapped up.
script runtime not ready UnityEngine.Debug:LogError (object) QuickJS.Unity.JSBehaviour:CreateScriptInstance () (at Assets/Jsb/Source/Unity/JSBehaviour.cs:661) QuickJS.Unity.JSInspectorBase
1<QuickJS.Unity.JSBehaviour>:EnableScriptInstance () (at Assets/Jsb/Source/Unity/Editor/JSInspectorBase.cs:257) QuickJS.Unity.JSInspectorBase
1:OnInspectorGUI () (at Assets/Jsb/Source/Unity/Editor/JSInspectorBase.cs:474) UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)
From the message provided, it does seem to be related to the editor and does not appear that it would affect the end product. Simply wanted to forward that message your way.
I've updated the editor of JSBehaviour. It's easier to toggle whether the JSBehaviour is updatable or not.
the error script runtime not ready
is caused by uncertain execution order, it's difficult to resolve, because the script engine initialization process could/should be asynchronous (e.g waiting for the async file system ready).
So, it's better and safer to wrap them in a prefab, and instantiate the scripted prefab in a script.
I have had a bit more time to explore unity-jsb, and have stumbled upon a place where I can initialize the runtime and receive
Awake
andOnEnable
calls to my script. It seems though that no otherMonoBehaviour
lifecycle methods are being called.Two scripts were created to handle creating and destroying the
ScriptRuntime
. I found that I needed to change the script execution order within Unity to have the runtime created before the majority of the other scripts were ran, and in like have the runtime destroyed following the other scripts.Everything seems to work without issue at this point. At least in the sense of no errors being thrown, and the console not reporting anything amiss. When I attach a
JSBehaviour
, with its source file pointing to the below script, to an empty object though, the runtime seems to fail at calling theUpdate
,OnDisable
, or theOnDestroy
methods that are defined. It does not report any issues to the Unity console, in fact it does not do anything despite theconsole.log
calls. As reported earlier, theAwake
andOnEnable
do correctly report their messages to the console.Have I done something incorrect in creating the runtime? I have tried comparing to the example projects from this repository, and I seem to have hit on all of the key points in creating and updating the runtime. Is there something amiss that I am overlooking?
Thank you!