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
Assetfolder copyPlugins,ScriptsandEditorto 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.plistinside theURL Typeskey
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).AuthorizeCallbackis a delegate taking anintand returningvoid. The passedintis eitherFacebook.LOGGED_INorFacebook.LOGGED_OUT. -
postToStream(Text, RequestCallback)postToStream(Text, Image, Link, Name, Caption, Description, RequestCallback)Posts something to the user’s stream.RequestCallbackis a delegate taking anintand astringand returningvoid. The integer is eitherFacebook.REQUEST_SUCCESSorFacebook.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