Question about facebook sdk init callbacks

Hello everyone.
I have to integrate the facebook sdk into my game to just get analytics about installs and app runs.
I don’t need any kind of fb social features.

So, EVERY guide tells me that I should get callback from FB.Init() and set Time.timescale to 0 or 1 by FB Callback "OnHideUnity(bool) " . Why is that? Completely no info about is it neccesary or why I should do that.
Why can’t I do that by native Unity “OnApplicationFocus(bool)”? Why can’t I leave timescale be independent from facebook? I’ve been searching this for about 4 hours and found absolutely nothing, except “Just do that”.

Setting Time.timeScale to zero makes all things dependent on that stop moving: Time, most animation, particles, etc.

Setting Time.timeScale back to 1 resumes normal motion. (And yes, setting it to 2.0 makes everything twice as fast!)

I can’t imagine why this would be necessary with FB. We don’t bother with this. When you leave Unity pretty much it stops running on iOS and Android, at least after a very short period allotted by the OS to let it write files to disk, etc.

All I can say is: try it without, see if anything goes wrong!

Thanks for reply)
Yes, I do know what timescale does with game and how it works. I just don’t understand why engine variable should be dependent from third party not best code. Second problem is I don’t know where to put my eye to see is it going wrong or not, so I decided to ask somebody who worked with it.

Why not use Unity Analytics? Unity - Manual: Unity Analytics

1 Like

Because we need FB. If I say I Have to integrate fb sdk, it means I have. Maybe I don’t want or there are a lot of analytics sdk I could use but I have to deal with fb)

But you don’t need the FB SDK just to get installs and app runs. Unity Analytics does that for free, without an SDK needed. Just turn it on in the Services window in the Editor, and you get install and app analytics. Perhaps you need to FB SDK for other reasons.

FB sdk is very usefull for targeting.

Finaly I’ve found the answer.
Thanks everyone for not answering the question and suggesting to do something I don’t need.

The answer is:
OnHideUnity(bool) method is called when facebook popups it’s own ui, so you better pause the game and be ready to lose focus.
My mistake was to thinking that this method called when unity app loses focus like native OnApplicationFocus (OnHideUnity method name says unity is hidden but doesn’t say “Hey we are showing our facebook specific stuff”).

Reference to docs for somebody who deal with that like me:

1 Like