Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Omer.Hussain · May 28, 2014 at 01:54 PM · facebook

How to share high score(string)/game result data on facebook ...please any one help me ....:(.

Friends i really need your help .... its been i am trying to just show my game result on facebook :(...what i want, at the end of my game i get a result in string like high score... i just want to show that on face book as to post on your own facebook wall ... i have installed facebook sdk 5.1, made an app id on developers.facebook page .. put that name and the app id in the facebook settings in the unity3d editor .. but i am not figuring it out how we will share the result ... i tried to get help from the friendssmash but its complicated .. they are not showing properly ... is there any other scripts that we need to write ..there will be ... please help me .. i am stuck at the end of my game .. :"(

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Omer.Hussain · Jun 03, 2014 at 07:16 AM

Actually in the fb.Init() i removed the OnHideUnity and it works ... in OnHideUnity game get pause before sharing .... strange ... Thanks for all of you for help ... :) ..

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by PouletFrit · May 28, 2014 at 02:19 PM

With the Facebook SDK for Unity you will need to call the FB.Feed function and give it the good parameters. Just add your score in the linkDescription or in the linkName.

Take a look at this link: FB.Feed Reference

Exemple:

 FB.Feed(
     link: "https://example.com/myapp/?storyID=thelarch",
     linkName: "The Larch",
     linkCaption: "I thought up a witty tagline about larches",
     linkDescription: "There are a lot of larch trees around here, aren't there?",
     picture: "https://example.com/myapp/assets/1/larch.jpg",
     callback: LogCallback
 );

 void LogCallback(FBResult response) {
     Debug.Log(response.Text);
 }
 


Comment
Add comment · Show 11 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Omer.Hussain · May 29, 2014 at 07:38 AM 0
Share

Thanks for your response , i know this is again dum question ... actually i am new to program$$anonymous$$g ... and just learn javascript yet ..... i wrote this ... i think i wrote it not correctly ..

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 using Facebook.$$anonymous$$iniJSON;
 using System;
 
 public class ButtonFbShare : $$anonymous$$onoBehaviour {
         
         string appid;
     void Awake(){
         FB.Init(SetInit, OnHideUnity);
         }
     private void SetInit() {
         enabled = true; 
         // "enabled" is a magic global; this lets us wait for FB before we start rendering
     }
     
     private void OnHideUnity(bool isGameShown) {
         if (!isGameShown) {
             // pause the game - we will need to hide
             Time.timeScale = 0;
         } else {
             // start the game back up - we're getting focus again
             Time.timeScale = 1;
         }
     }
 
 
     void On$$anonymous$$ouseDown(){
                 FB.Feed (
         link: "https://developers.facebook.com/apps/"+appid,
         linkName: "Love$$anonymous$$eLove$$anonymous$$eNot",
         linkCaption: "Here is the Result of my Love$$anonymous$$eLove$$anonymous$$eNot Result",
         linkDescription: "$$anonymous$$y Love$$anonymous$$eLove$$anonymous$$eNot Result is Perfect"
 //        picture: "https://example.com/myapp/assets/1/larch.jpg",
 //        callback: LogCallback
             );
         }
 }


shows me this error

NullReferenceException: Object reference not set to an instance of an object UnityEngine.GUILayoutUtility.DoGetRect (UnityEngine.GUIContent content, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/GUILayoutUtility.cs:264) UnityEngine.GUILayoutUtility.GetRect (UnityEngine.GUIContent content, UnityEngine.GUIStyle style) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/GUILayoutUtility.cs:257) Facebook.FbSkinnedDialog.TwoButtonBar (System.String label, System.String cancelLabel) Facebook.FeedDialog.UpdateDialog (Int32 windowID) Facebook.FbSkinnedDialog.GeneralUpdateDialog (Int32 windowId) UnityEngine.GUI.CallWindowDelegate (UnityEngine.WindowFunction func, Int32 id, UnityEngine.GUISkin _skin, Int32 forceRect, Single width, Single height, UnityEngine.GUIStyle style) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/GUI.cs:1395)

avatar image Kiwasi · May 29, 2014 at 09:52 AM 0
Share

To fix the optional parameter error move line 17 to the top of the parameters list. Or give it a default value.

avatar image PouletFrit · May 29, 2014 at 11:35 AM 0
Share

I think ur getting this error because u are running it in the editor.

Have u tryed to test it directly on facebook?

avatar image PouletFrit · May 29, 2014 at 11:40 AM 0
Share

Also there should be somewhere in ur script that you use FB.Login, otherwise i doubt that you will be able to use FB.Feed

 private void SetInit() {
     FB.Login("publish_actions", OnLoggedIn);
 }
 
 void OnLoggedIn(FBResult result) {
     if (FB.IsLoggedIn) {
         Debug.Log("Logged in successfully");
     }
 }
avatar image Omer.Hussain · May 29, 2014 at 01:21 PM 0
Share

now i have updated the code just for test .... run on my android device ... when i click the login button it show facebook page to login... after log in its ask me that this app wants your friends ,pics etc etc etc type... i click ok .. after that it doesn't show the next activity in which we select our friend or post on our on wall ....i think the error could be because in the face book setting it doesn't show hash key .. is this happening because of hash key ... ?

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 using Facebook.$$anonymous$$iniJSON;
 using System;
 
 public class ButtonFbShare : $$anonymous$$onoBehaviour {
 
     void Start()
     {
         FB.Init(OnInitComplete, OnHideUnity);
     }
     
     void OnInitComplete()
     {
         Debug.Log("FB Initialized");
     }
     
     void OnHideUnity(bool isGameShown)
     {
         Debug.Log("OnHideUnity");
         if (!isGameShown)               
             Time.timeScale = 0;
         else
             Time.timeScale = 1;
     }
     
     void Update()
     {
         
     }
     
     void OnGUI()
     {
         if (!FB.IsLoggedIn)
         {
             if (GUI.Button(new Rect(10, 10, 100, 30), "Login"))
                 FBLogin();
         }
         else
         {
             if (GUI.Button(new Rect(10, 50, 100, 30), "Brag"))
             {
                 Brag();
             }
         }
         
     }
     
     void Brag()
     {
         FB.Feed(
             linkCaption: "This is testing the testapp FEED",
             picture: "http://myapp.com/myapplogo.jpg",
             linkName: "Foo Link",
             link: "http://apps.facebook.com/" + FB.AppId + "/?challenge_brag=" + (FB.IsLoggedIn ? FB.UserId : "guest")
             ); 
     }
     
     void FBLogin()
     {
         FB.Login("email, publish_actions", OnLoggedIn);
     }
     
     void OnLoggedIn(FBResult result)
     {
         if (FB.IsLoggedIn)
             Debug.Log("Logged in successfully");
     }
 }

 
Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Facebook Canvas unable to get profile picture 1 Answer

Openssl not found in unity sdk for facebook 6 Answers

How to stop facebook sdk logs? 0 Answers

Can't submit facebook app for review 1 Answer

unity not respoding - stuck by clicking on facebook setting 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges