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
0
Question by dabears · Sep 03, 2014 at 09:48 PM · c#achievements

Help implementing Achievements

I have read over the Social API [guide][1]

And attempted an implementation

     public class SocialController : MonoBehaviour {
         
         PlayerController playerController = null;
 
         IAchievement scoreAchievement = null;
         ILeaderboard leaderboard = null;
 
         public SocialController() {
         }
 
         void Start() {
             if (playerController == null) {
                 playerController = GameObject.FindGameObjectWithTag("Player").AddComponent<PlayerController>();
             }
 
 
             // Authenticate and register a ProcessAuthentication callback
             // This call needs to be made before we can proceed to other calls in the Social API
             Social.localUser.Authenticate(ProcessAuthentication);
 
             leaderboard = Social.CreateLeaderboard();
             leaderboard.id = "MainLeaderboard";
             leaderboard.LoadScores(result => {
                 Debug.Log("Received " + leaderboard.scores.Length + " scores");
                 foreach (IScore score in leaderboard.scores)
                     Debug.Log(score);
             });
 
 
             IAchievement achievement = Social.CreateAchievement();
             achievement.id = "Achievement01";
             achievement.percentCompleted = playerController.SCORE;
             achievement.ReportProgress(result => {
                 if (playerController.SCORE > 100)
                     Debug.Log("Successfully reported progress");
                 else
                     Debug.Log("Failed to report progress");
             });
         }
 
         // This function gets called when Authenticate completes
         // Note that if the operation is successful, Social.localUser will contain data from the server. 
         void ProcessAuthentication(bool success) {
             if (success) {
                 Logger.logSocial("Authenticated, checking achievements");
 
                 // Request loaded achievements, and register a callback for processing them
                 Social.LoadAchievements(ProcessLoadedAchievements);
             } else
                 Logger.logSocial("Failed to authenticate");
         }
 
         // This function gets called when the LoadAchievement call completes
         void ProcessLoadedAchievements(IAchievement[] achievements) {
             if (achievements.Length == 0)
                 Logger.logSocial("Error: no achievements found");
             else
                 Logger.logSocial("Got " + achievements.Length + " achievements");
 
             // You can also call into the functions like this
             Social.ReportProgress("Achievement01", 100.0, result => {
                 if (result)
                     Logger.logSocial("Successfully reported achievement progress");
                 else
                     Logger.logSocial("Failed to report achievement");
             });
         }
     }

 


*ignore the Leaderboard, that'll probably be my next question to post

However it seems like Im missing a call to save my custom achievement, or maybe not understanding how to use this API. Because all I get from doing this is an error:

Failed to report progress

UnityEngine.Debug:Log(Object) TikiBeeGame.SocialController:m__1(Boolean) (at Assets/MyScripts/SocialController.cs:50) UnityEngine.SocialPlatforms.Impl.Achievement:ReportProgress(Action`1) TikiBeeGame.SocialController:Start() (at Assets/MyScripts/SocialController.cs:46) as well as a message

Error: no achievements found

UnityEngine.Debug:Log(Object) TikiBeeGame.Logger:logSocial(String) (at Assets/MyScripts/Logger.cs:37) TikiBeeGame.SocialController:ProcessLoadedAchievements(IAchievement[]) (at Assets/MyScripts/SocialController.cs:100) UnityEngine.Social:LoadAchievements(Action`1) TikiBeeGame.SocialController:ProcessAuthentication(Boolean) (at Assets/MyScripts/SocialController.cs:92) UnityEngine.SocialPlatforms.Impl.LocalUser:Authenticate(Action`1) TikiBeeGame.SocialController:Start() (at Assets/MyScripts/SocialController.cs:33) [1]: http://docs.unity3d.com/Manual/net-SocialAPI.html
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

0 Replies

· Add your reply
  • Sort: 

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

2 People are following this question.

avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Renderer on object disabled after level reload 1 Answer

Google play achievements problem please help 2 Answers

Achievements Google Play. 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