Maybe it’s possible…
As I understand it, you can’t really do anything to your Unity-built iPhone once it gets to the Cocoa stage. So, no.
I’ve got it working. Screenshots to follow.
Here’s a shot of the FaceBook Connect window over the top of the Unity game. (I was asked to change the name of the game, that font is slightly different.)
The FaceBook protocol sure is verbose.
Woooww!
Amazing!
But, the question is,…how??
xD
Starting from a project with the Enhancement Pack installed (if you don’t have it, be sure to save your changes between Unity builds):
-
Follow the FBConnect README and add the FBConnect group to your project, and add the path to /src to your user include paths
-
Add a FBSession* to the application, and inititalize it when the app starts. I use a delayed method call in applicationDidFinishLaunching: to call this code:
session = [FBSession sessionForApplication: @"appkey" secret:@"secret" delegate:self];
if ([session resume] == NO) {
FBLoginDialog* dialog = [[[FBLoginDialog alloc] init] autorelease];
[dialog show];
}
-
Add the necessary delegates, like session:didLogIn:
-
Try it!
This doesn’t do anything but log in. I’ve got it pulling profile pictures and applying them to textures, too, but I am just now learning the FaceBook API, and there’s a tremendous amount of stuff there. It seems like it will take a lot longer to integrate this than, say, SmartFox Server chat did. But maybe I’ll figure it all out quickly. I haven’t figured out best/simplest/generic integration between Unity and FBC. There are many different FaceBook API calls, and different ways to call them. And there are several callbacks.
We’re gonna need a JSON parser inside Unity. Anyone got one already?
Hhuuum, thanks for your help!
So, list of friends or invite friends it’s not possible?
It’s totally possible. You get the list of friends with “friends.get” and that returns an array of friend IDs. You then go through that list of friend IDs and call “users.getInfo” on them, to get their names.
That’s about as deep as I’ve gotten into the API myself, but I’m sure there are others here who can chime in and explain how to do the cool stuff.
Bliprob, amazing work as always.
Is there a json reader in C# that can be used as a base?
Turns out FBConnect is bridging FaceBook JSON into Cocoa objects (i.e. NSArray of NSDictionary objects). They’re probably using TouchJSON internally. So it should be easy to dump those into strings with whatever formatting you like and pass them back to Unity.
Woot, is this already in the build that I purchased or is it in a new build? Do I need to pay an upgrade license? I seriously want this
This isn’t in the Enhancement Pack right now. I’m just playing around with it for now. I’d have to think about how to include it (not even sure if the licensing would allow me to). But you can add it with the instructions I gave above, email me if you run into trouble.
Pleeease, do it!
Include it!
We’ve got a JSON parser that runs in Unity, so you can get access to the data in-engine which can be a lot more convenient. Rob, we could include it in the Enhancement pack if you like, or I guess we could make it available to people outside of that if anyone’s interested.
Rj
I’m interested. xD
Im also very interested in a json parser in C# that I can send a json String into or something similr and get C# objects out of
M
We are packaging up our JSON parser and will be making it available shortly, I’ll keep you informed.
Just to be clear, you don’t need to parse JSON to use the FaceBook API. The API handles the JSON parsing and you get Cocoa objects (i.e. an NSArray of NSDictionaries) that you’ll convert to strings to send to Unity.
…If your desire for a JSON parser isn’t related to using the FaceBook API, apologies for the interruption! (Looking forward to it spinfast!)
How’s this looking. I’m interested in checking it out
Tell us more! MORE!