Search Unity

Unity / Facebook integration

Discussion in 'General Discussion' started by Tom163, Nov 12, 2009.

  1. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,290
    I've been fighting with Facebook for the better part of a week now, and finally, I have it.

    This demo shows a framework for integrating Unity3D with Facebook, with data exchange in both directions:

    http://www.facebook.com/apps/application.php?id=192719246213

    Please note that even though nothing visible happens, a story does get posted to your wall, so don't click that button more than once. I tried going with dialogs, but they don't work properly for iframe apps.

    In a real app, of course, you'd not have a button, you'd post highscores or events, or whatever.

    Posting title, text and image are fully configurable in the framework and can be different for each posting.


    I hope Unity doesn't mind that I use Lerps portrait for the story image.
     
  2. vishesh-l

    vishesh-l

    Joined:
    Feb 14, 2010
    Posts:
    27
    thats awesome...a tut for this ?
    please...or if u can attach the scripts ant the stuff that u did on facebook to make this work
     
  3. DavidB

    DavidB

    Joined:
    Dec 13, 2009
    Posts:
    530
    This is very interesting, I would be interested in knowing how you went about this too if you are at liberty to discuss it that is.

    Cheers and great work!
     
  4. Robert G

    Robert G

    Joined:
    Nov 17, 2009
    Posts:
    233
    I’m curious to see this, unfortunately I get an error when I try to post a message:

    message = is playing around
    caption=Still working his way through the docs and wiki, {*actor*} is not yet giving up on the facebook API.
    image_url=http://download.unity3d.com/support/resources/images/3d-platform-game-logo-small.png
    image_link=http://unity3d.com
    action_name=Visit Unity3D
    action_link=http://unity3d.com
     
  5. DavidB

    DavidB

    Joined:
    Dec 13, 2009
    Posts:
    530
    @Robert G:

    I get the same thing, but if you check your wall, you'll see it actually makes a post. Some kinks may have to be worked out, but it does seem this is a step in a very cool direction. Does everyone else see that error?
     
  6. Lukas H

    Lukas H

    Joined:
    Jan 16, 2009
    Posts:
    394
    Tom, have you seen Tempest (Nick Breslin) topic/tutorial about Unity-Facebook integration?
    Its great and helps you smooth out all the bumps there are on the road. He created an example project along with it.

    Take a look his topic:
    http://forum.unity3d.com/viewtopic.php?t=35974
    His blog is also a great source of information for Facebook - Unity related stuff.
     
  7. YorickVanVliet

    YorickVanVliet

    Joined:
    Nov 14, 2009
    Posts:
    22
    The need for extended permissions is really a setback, most people wont grant you them. (And they are right, since a lot of Facebook Apps spam continue to spam their users!)

    Extended permissions could improve the usability, but make them optional. The user should be able to use your application without granting Extended Permissions.
    One problem is that Facebook's dialogs won't show on top of Unity, to solve that you can temporary hide the Unity screen.

    This bit of Javascript will hide and show the Unity window:
    Code (csharp):
    1. var OldSize = { 'width' : GetUnity().style.width,
    2.                 'height' : GetUnity().style.height };
    3.  
    4. function IsUnityHidden()
    5. {
    6.     return GetUnity().style.width != OldSize.width
    7.             GetUnity().style.height != OldSize.height;
    8. }
    9.  
    10. function ToggleUnity()
    11. {
    12.     if(IsUnityHidden())
    13.     {
    14.         GetUnity().style.width = OldSize.width;
    15.         GetUnity().style.height = OldSize.height;
    16.     } else {
    17.         GetUnity().style.width = 1;
    18.         GetUnity().style.height = 1;
    19.     }
    20. }
    21.  
     
  8. mcarr1973

    mcarr1973

    Joined:
    Apr 25, 2008
    Posts:
    81
    Hello Tom,

    Wow This is really awesome and exactly what Im looking for :)

    Is there anyway you can share the example code or the project files for how you did this? or possibly a tutorial on how you did this?

    I was also noticing the that the lerpz publish or skip option is under the unity player but its seems Tijmen may have solved the problem ;) Have you tried his little bit of code?

    Sincerely,
    Michael
     
  9. purpleslurple

    purpleslurple

    Joined:
    Mar 8, 2010
    Posts:
    4
    Does anybody know where I can find samples/code/details on integrating facebook connect with my iphone app from within Unity iPhone?
     
  10. purpleslurple

    purpleslurple

    Joined:
    Mar 8, 2010
    Posts:
    4
  11. eviltenchi_84

    eviltenchi_84

    Joined:
    Feb 18, 2010
    Posts:
    99
    is there a way to do that hide in Unity iPhone? GetUnity seems to only work in normal Unity.
     
  12. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    this is for the webplayer and will not work on the iphone at all.
     
  13. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    If you want to connect with Facebook in your iPhone apps then take a look at the Unity iPhone Enhancement Pack as it now exposes the Facebook iPhone APIs.
     
  14. yahodahan

    yahodahan

    Joined:
    Apr 26, 2009
    Posts:
    1,380
    resurrection! (bwaaaa-uuRRRGg!!)

    erm, before this post goes zombie, does anyone know if the facebook enhancements from that "iPhone Enhancement Pack" were built into Unity 3.0?

    thanks!
     
  15. ThanNewell

    ThanNewell

    Joined:
    May 4, 2011
    Posts:
    9
    Setting the height and width doesn't seem to effect my plugin. Did this get disabled? Anyone know of another way to accomplish this?

    Update: Firefox the pay dialogue displays just fine. Chrome(Rockmelt) it does not.
     
    Last edited: Nov 7, 2011
  16. Tellus

    Tellus

    Joined:
    Nov 4, 2012
    Posts:
    5
  17. Jdb9878

    Jdb9878

    Joined:
    Feb 3, 2015
    Posts:
    1
    Is there a way someone can explain this in a way a new person to this can understand and accomplish this task?
    I've build a game, but I am unable to share it, and I'm not able to post to facebook.

    What must I do to the game to add it to facebook?