Unity still has a lot of shortcomings. This library is supposed to make life easier when developing Unity applications - especially mobile ones.
It’s rather empty right now, but it will grow with time.
-
Initialize the submodules
$ git submodule init $ git submodule update
-
From the
Asset
folder copyPlugins
,Scripts
andEditor
to your Unity project
- Create a new, empty Object in Unity’s inspector and name it “Facebook”
- Attach the Facebook script to it
- Set it App Id in the script’s properties
- Before compiling in XCode, replace “[YOUR APP ID]” with your Facebook app id in
Info.plist
inside theURL Types
key
Right now the Facebook module is kind of awkward. Please note, that I am aware of this fact ;) You can call any of the below methods on the script instance which you can access by calling
Facebook.getInstance()
-
compilePermissions(...)
Compiles the given permission flags to a single integer whichauthorize()
will accept -
authorize(Permissions, AuthorizeCallback)
Requests the given permissions from the user (seecompilePermissions
).AuthorizeCallback
is a delegate taking anint
and returningvoid
. The passedint
is eitherFacebook.LOGGED_IN
orFacebook.LOGGED_OUT
. -
postToStream(Text, RequestCallback)
postToStream(Text, Image, Link, Name, Caption, Description, RequestCallback)
Posts something to the user’s stream.RequestCallback
is a delegate taking anint
and astring
and returningvoid
. The integer is eitherFacebook.REQUEST_SUCCESS
orFacebook.REQUEST_FAIL
. The string contains the JSON formatted result or error. -
logout()
- Get a proper callback infrastructure running. Using
UnitySendMessage()
is not really the nice way to get data back to C#.
Under Creative Commons 3.0 BY-NC-SA this is for free. For 10€ you can get a commercial license. [Contact me][mailto:surma@asdf-systems.de].
by Alexander Surma surma@asdf-systems.de JSONKit by johnezang