public void InitScript() { if (!JSEngine.inited) { return; } go = JSApi.JSh_NewObjectAsClass(JSMgr.cx, JSMgr.glob, "GameObject", JSMgr.mjsFinalizer); if (go == IntPtr.Zero) { return; } JSApi.JSh_AddObjectRoot(JSMgr.cx, ref go); JSMgr.addJSCSRelation(go, gameObject); IntPtr ptrScript = JSMgr.GetScript(jsScriptName); if (ptrScript == IntPtr.Zero) { Debug.Log("ptrScript is null)"); enabled = false; return; } if (!JSMgr.ExecuteScript(ptrScript, go)) { Debug.Log("---------- ExecuteScript fail"); enabled = false; return; } funAwake = JSApi.JSh_GetFunction(JSMgr.cx, go, "Awake"); funStart = JSApi.JSh_GetFunction(JSMgr.cx, go, "Start"); funUpdate = JSApi.JSh_GetFunction(JSMgr.cx, go, "Update"); funDestroy = JSApi.JSh_GetFunction(JSMgr.cx, go, "Destroy"); funOnGUI = JSApi.JSh_GetFunction(JSMgr.cx, go, "OnGUI"); if (funAwake != IntPtr.Zero) { JSMgr.vCall.CallJSFunction(go, funAwake, null); } inited = true; }