Search Unity

ui button doesn't work after pressing home button on iPhone

Discussion in 'Scripting' started by whoseline, Jul 16, 2015.

  1. whoseline

    whoseline

    Joined:
    Dec 22, 2012
    Posts:
    11
    My scene has :
    * canvas for 3 buttons . 1 for sound , 1 for play and 1 for leaderboard ( game center ).
    * game object for game center link with a script . script is :

    --------------------------------------------------------------------------------------
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.SocialPlatforms.GameCenter;
    3. using System.Collections;
    4.  
    5. public class gamecenterlink : MonoBehaviour {
    6.  
    7. public int highScore;
    8.  
    9.  
    10. public string leaderboardName = "";
    11. public string leaderboardID = "";
    12.  
    13. void Start ()
    14. {
    15. highScore = PlayerPrefs.GetInt ("highScore");
    16.  
    17. #ifUNITY_IPHONE
    18. if (!Social.localUser.authenticated)
    19. Authenticate();
    20.  
    21. #endif
    22. }
    23.  
    24. private void NullMe(boolsuccess)
    25. {
    26.  
    27. }
    28.  
    29. public void Authenticate()
    30. {
    31. #ifUNITY_IPHONE
    32. Social.localUser.Authenticate(NullMe);
    33. #endif
    34. }
    35.  
    36.  
    37. public void ReportScore(stringleaderboardID, longhighScore)
    38. {
    39. #ifUNITY_IPHONE
    40. Social.ReportScore(highScore, leaderboardID, NullMe);
    41. #endif
    42. }
    43.  
    44.  
    45.  
    46. public void ShowLeaderboard()
    47. {
    48. #ifUNITY_IPHONE
    49.  
    50. ReportScore(leaderboardID,highScore);
    51. Social.ShowLeaderboardUI();
    52. #endif
    53. }
    54.  
    55.  
    56. }
    ------------------------------------------------------------------

    *I linked leaderboard button to this script's ShowLeaderboard() part .

    when I start the game everything is normal . if I wanna see the leaderboard I return to this main scene . I click leaderboard button , game center opens and I can see everything. I can do that over and over .
    But when I press home button on my iPhone , my game goes to background as you know . when I press my game's shortcut and call my game back ... ui button for leaderboard stops working . it's still clickable but it does nothing. game center doesn't opens anymore. anyone can help ? I tried ui change , button change , game center script change. all the same .
    testing phone is iPhone 4 8gb . iOS 7 . thanks .
     
    Last edited: Jul 16, 2015
  2. renton1990

    renton1990

    Joined:
    Dec 1, 2014
    Posts:
    2
    Oh, I met the same issue. I test my game on iPhone5S and iOS simulator. Maybe it's a bug of Unity?
     
  3. kyuskoj

    kyuskoj

    Joined:
    Aug 28, 2013
    Posts:
    56
    Yes this is probably a Unity issue. because it works fine on Unity 5.1.0 version
     
  4. kyuskoj

    kyuskoj

    Joined:
    Aug 28, 2013
    Posts:
    56
    This issue is occurred not only game center but also all ios native dialogue.
     
  5. renton1990

    renton1990

    Joined:
    Dec 1, 2014
    Posts:
    2
    Hope the issue will be fixed on Unity 5.2.:(