Closed Gentatsu closed 5 years ago
What's your Discord username? If you're on not there, I would recommend you to make an account. All support and such happens there and i would like to ask you some questions about this. Else, we'll take it here
Oh wait, you need to run it inside the main thread manager, as it's an Forge event. https://github.com/BeardedManStudios/ForgeNetworkingRemastered/wiki/Running-Unity-Specific-Code-on-the-Main-Thread
I thought it might've been a main thread issue. Would it be possible to add a warning/error when code that requires main thread execution tries to execute on a separate thread?
I'll give it a try and let you know if it works. I'll also try make a Discord account!
I circumvented the issue initially by setting a boolean, and in the Update function, I set a timeout of 0.5 seconds for the UDP announcements, and perform my function then (showing a list of hosts).
I would rather just add each host on the callback, though!
The Unity editor should have given you an error. Though, why not just use the MainThreadManager.Run() inside your event method? That should do it
No errors! I didn't know about the Main thread manager =P!
I did try it, and it's still not working!
I'm calling it using a lambda function: MainThreadManager.Run(() => AddRow(endpoint));
, and it's giving me the same issue. Again, no errors!
Can you show me the fullcode?
Refresh
is called on a button OnClick. I've commented some of it out since I was doing a refresh check for a host every second, but also had the manual button.
You are still running Unity code inside the Forge event. Just wrap the whole entire "LocalServerLocated" in it, so it look something like this: https://pastebin.com/7kL5g47M
Debug.Log was in the example in the documentation, and runs fine.
When I wrap it up like in yours, none of it gets called.
Join the Discord and let's have a chat
Issue was asset store version. This works in the latest of master branch release.
Version Number and Operating System(s): Unity 2018.3.7f1 & Forge 25.01
Expected behavior: Code in callback to work (Instantiating game objects or other 3D object manipulation)
Actual behavior: Code does not get executed beyond trying to use any Gameobject references.
Steps to reproduce:
Add callback to localServerLocated Any code manipulating endpoint data works fine. Try to Instantiate a gameobject or change any properties (or call GetComponent), and it will stop executing without an error.
[Optional] Discord Username: