Hi,
I'm working on a Unity project and I'm very excited to see that you've chosen a AS3.0-like approach (which is the programming language I'm coming from) for the UnityClient API.
In Unity I've made a login scene with a GUI and a script, in which the connection with SmartFox seems to work like a charm. The only problem is when I switch to a new game scene by calling Application.LoadLevel("gameScene") with it's own script I no longer seem to be able to add eventlisteners to the smartfox object ( or at least the callbacks in this new script won't get called).
I'm referencing the smartfox object in both scripts via a static instance in a SmartFoxHolder class, very much like in the examples. Somehow the requests do reach the server. It's just that the callbacks aren't excecuting after the requests have been send.
EDIT: I did use the RemoveAllEventListeners() on the smartfox object right before loading the new scene, and tried reassigning them in the new scene. After this reassigning-part is where things go silent.
Any help on the situation would be much appreciated.
SFS2X callbacks won't get called after LoadLevel()
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
Boy, oh boy.. do I feel stupid now.
The ActionScript-like namingconvention which I like so much, got me on this one. It was just a silly typo on the FixedUpdate call for Unity. Since I named it OnFixedUpdate, the smartfox.ProcessEvents() wouldn't get called in the gameScene. Both me and one of my colleagues completely missed it on the error-tracking.
Fixed it now. Thanks for the reply anyway.
The ActionScript-like namingconvention which I like so much, got me on this one. It was just a silly typo on the FixedUpdate call for Unity. Since I named it OnFixedUpdate, the smartfox.ProcessEvents() wouldn't get called in the gameScene. Both me and one of my colleagues completely missed it on the error-tracking.
Fixed it now. Thanks for the reply anyway.
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
Ahhhh - super!! You had me worried for a few seconds
But yeah - the requirement of the fixed update can be tricky to spot. Got any good ideas on how to make it more obvious? (I dont)
Especially if you are also using Unity 3, the thread safety will simply force you to use this way to empty the response queue - else you game crashes hard. Thats why I made it default mode in the new API
Shoot away with questions if you run into anything else - anything at all
/Thomas
But yeah - the requirement of the fixed update can be tricky to spot. Got any good ideas on how to make it more obvious? (I dont)
Especially if you are also using Unity 3, the thread safety will simply force you to use this way to empty the response queue - else you game crashes hard. Thats why I made it default mode in the new API
Shoot away with questions if you run into anything else - anything at all
/Thomas
Who is online
Users browsing this forum: No registered users and 69 guests