Agora_Unity_WebGL icon indicating copy to clipboard operation
Agora_Unity_WebGL copied to clipboard

[Solved FAQ] Reference error: UnityHooks its not defined

Open Mallo-Lucas opened this issue 3 years ago • 27 comments

Hello! i managed to make a build on the demo project, at the branch dev/refactor4, but when i test it i have this errors: imagen

i make the build on Unity 2021.3.4f1

Mallo-Lucas avatar Jul 06 '22 23:07 Mallo-Lucas

Is this error is unity version specific? Any specific unity version where this error is not coming? I used 2019.4.6f1 and I got the error.

Any lead for this will be helpful.

BavishiDhruvil avatar Jul 12 '22 13:07 BavishiDhruvil

@Mallo-Lucas did you choose AgoraTemplate2020 for building the project? @BavishiDhruvil did you choose AgoraTemplate to make the build?

Have you look at the README files regarding building and running projects with the SDK? If setting the template doesn't work for you. Then try to start fresh with your project and try to import the SDK again.

icywind avatar Jul 15 '22 21:07 icywind

Any one encounter the same issue - make sure you have a clean project that previous cache of WebGL SDK is not present. I will keep this issue open for 30 days before closing it.

icywind avatar Jul 20 '22 00:07 icywind

@BavishiDhruvil did you choose AgoraTemplate to make the build?

Yes. I have.

BavishiDhruvil avatar Jul 21 '22 14:07 BavishiDhruvil

Try start your project clean without the SDK and then import it.

icywind avatar Jul 22 '22 18:07 icywind

 replace 
  // Runtime.dynCall('viiiii', UnityHooks.OnStreamMessageCallback, [uid, 0, data, length]);
  by
  Module['dynCall_viiiii'](UnityHooks.OnStreamMessageCallback, uid, 0, data, length);

tuannhanle avatar Jul 28 '22 10:07 tuannhanle

noitice 5 letters i

tuannhanle avatar Jul 28 '22 10:07 tuannhanle

@BavishiDhruvil I've pushed the change that @tuannhanle suggested. Would you please try it out on branch dev/refactor5?

icywind avatar Aug 03 '22 20:08 icywind

@BavishiDhruvil I've pushed the change that @tuannhanle suggested. Would you please try it out on branch dev/refactor5?

Checking this.

BavishiDhruvil avatar Aug 04 '22 05:08 BavishiDhruvil

@icywind @tuannhanle This works fine with 2019.4.6f1 is working fine. But still the same error in 2020.3.18f1 is having the same error.

Really appreciate your help.

Thanks, Dhruvil

BavishiDhruvil avatar Aug 04 '22 06:08 BavishiDhruvil

I have the same error. I'm using Unity 2021.2.7f. I also tried the dev/refactor5 branch but without results.

I would appreciate any help on this matter

Klaus1991 avatar Aug 04 '22 12:08 Klaus1991

Unity 2019.4 works fine but Unity2020/Unity2021 doesn't want to work with AgoraTemplate2020

Klaus1991 avatar Aug 05 '22 08:08 Klaus1991

@BavishiDhruvil @icywind Can you help with this?

Klaus1991 avatar Aug 05 '22 08:08 Klaus1991

agora If I remove any mention of "UnityHooks" agora2 I get this error

Klaus1991 avatar Aug 05 '22 09:08 Klaus1991

Hi team,

I still face this problem on Unity 2021.3.8 and SDK v4.13.0-special.0-0-g967eedaf

image

Debug.Log("11111");
InitGameObject();
Debug.Log("2222");
InitEngineCallback();
Debug.Log("33333");

as you can see.. it fail when calling InitEngineCallback inside IRtcEngine

BinhTopebox avatar Sep 01 '22 22:09 BinhTopebox

@BinhTopebox are there any modification to the webgl build template? What if you build and run the demo or any of the API-examples?

icywind avatar Sep 01 '22 23:09 icywind

@icywind I just tried to build the demo and still get the same error. I have no modifications to the webgl build template

image

BinhTopebox avatar Sep 02 '22 00:09 BinhTopebox

I have the same problem... pls solve thanks

hoangndgcs18383 avatar Sep 02 '22 09:09 hoangndgcs18383

Hi guys, I managed to solve the problem. The problem was that I was using git project instead of unitypackage from realease section. As soon as I created a new Unity project and imported the unitypackage, the error disappeared.

Hope this helps someone

Klaus1991 avatar Sep 02 '22 10:09 Klaus1991

Would you share any changes after you imported this package again? maybe I changed setting at SDK that couldn't able to build in WebGL

hoangndgcs18383 avatar Sep 02 '22 10:09 hoangndgcs18383

After I completely remove the sdk, clear all unity cache, then reimport the sdk, it works like a charm.

Thank @Klaus1991, you saved my life :)

BinhTopebox avatar Sep 02 '22 15:09 BinhTopebox

Hi guys,

I am getting error in 2020.3.18 version.

Uncaught ReferenceError: unityFramework is not defined at r.onload

Any idea? I have created afresh project and imported the package from release.

Thanks, Dhruvil

BavishiDhruvil avatar Sep 07 '22 06:09 BavishiDhruvil

I have a related issue.

When I run the build locally it works great.

When I upload the build to simmer.io (a Unity WebGL hosting site), I get the UnityHooks not defined.

I don't know what would be different between running it locally and running it from that server.

Ideas?

tpitman avatar Oct 24 '22 16:10 tpitman

@tpitman no idea. As we have not gotten the chance to use simmer.io yet. If you found out something please share with the people. TIA!

icywind avatar Nov 03 '22 00:11 icywind

Looks like simmer replaces the template with their own.

I am working with the dev to fix that.

I uploaded to github pages and that works.

Thanks

On Wed, Nov 2, 2022 at 6:04 PM Rick Cheng @.***> wrote:

@tpitman https://github.com/tpitman no idea. As we have not gotten the chance to use simmer.io yet. If you found out something please share with the people. TIA!

— Reply to this email directly, view it on GitHub https://github.com/AgoraIO-Community/Agora_Unity_WebGL/issues/116#issuecomment-1301507331, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWFTQ46IORLX3VQ4TPH2VLWGL6QBANCNFSM523OHA7Q . You are receiving this because you were mentioned.Message ID: @.***>

tpitman avatar Nov 03 '22 00:11 tpitman

@tpitman good to know, thanks! As a hint for the other developers, the UnityHook not defined error is usually something related to the template not being loaded properly. In some other cases, such as wrapping the Unity WebGL build inside a React Native framework, could also cause the error. So the effort here is ensure the jslib and the included js source file are loaded and visible in that framework.

icywind avatar Nov 03 '22 00:11 icywind

Thanks!

On Wed, Nov 2, 2022 at 6:09 PM Rick Cheng @.***> wrote:

@tpitman https://github.com/tpitman good to know, thanks! As a hint for the other developers, the UnityHook not defined error is usually something related to the template not being loaded properly. In some other cases, such as wrapping the Unity WebGL build inside a React Native framework, could also cause the error. So the effort here is ensure the jslib and the included js source file are loaded and visible in that framework.

— Reply to this email directly, view it on GitHub https://github.com/AgoraIO-Community/Agora_Unity_WebGL/issues/116#issuecomment-1301510290, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWFTQ7BONKADOEK4QHZT2LWGL7E5ANCNFSM523OHA7Q . You are receiving this because you were mentioned.Message ID: @.***>

tpitman avatar Nov 03 '22 00:11 tpitman