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 mdagreda · Oct 21, 2012 at 05:38 PM · systemsocialleaderboards

What is System.Action?

I am trying to put leaders boards into my game and I am trying to use Social.ReportScores, but for it's parameters it asks for (score : Int64, board : String, callback : System.Action). I don't know what the System.Action is. If any one knows what this is or knows how to use Social.ReportScores then I could really appreciate your help. I've been stuck on making leaderboards for about two months now.

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

1 Reply

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

Answer by dannyskim · Oct 22, 2012 at 05:33 AM

An Action delegate is put simply an encapsulated method that returns no value, or a void encapsulated method. In this use case, it is acting as a call back that will fire off depending on what the type T is passed in for the System.Action, where T is a boolean variable.

http://msdn.microsoft.com/en-us/library/018hxwa8.aspx

So,

 Social.ReportScore (score, leaderboardID, success => {
         Debug.Log(success ? "Reported score successfully" : "Failed to report score");
     });

as shown in the Unity doc's above, the Debug.Log statement will print "Reported Score Successfully" if success = true, which is executed by the ReportScore method, or Debug.Log will print "Failed to report score" if success = false is set by ReportScore.

That essentially is what a "call back," is, it's calling your encapsulated method or bool upon completion. the => is a lambda expression, which is basically denoting you creating an anonymous method to pass as the callback, but you can still pass in a method if you wish as long as the method signature matches the type set by the Action, which is once again, a boolean. For example:

 Social.ReportScore( score, leaderboardID, DidCallBackReturnTrue );
 
 public void DidCallBackReturnTrue( bool isTrue )
 {
     if( isTrue )
         Debug.Log( "Report Score successful" );
     else
         Debug.Log( "Report Score failed" );
 }

So, to put it in plain english, the ReportScore method is asking you what do you want to do in the case that ReportScore is successful, or ReportScore failed.

If this is still going over your head, which it may be as it's admittedly a difficult concept to grasp as it was for me being a starter as well, this video may help from community member Prime31:

http://www.youtube.com/watch?v=7KBmZvpguWk&feature=relmfu

as with his delegates and events video that links to this.

Comment
Add comment · Show 1 · 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 mdagreda · Oct 26, 2012 at 08:40 PM 0
Share

Thanks, that is very helpful. :)

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

10 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

Related Questions

Social.ShowLeaderboardUI not showing up on MacOS Standalone 0 Answers

Social Api causing crashes 2 Answers

iOS Game Center displays "No Challenges" Instead of Achievements/Leaderboards 3 Answers

play-games-plugin: Loadscores ignore leaderboard's range settings 1 Answer

Did Social.LoadUsers() stop working? 3 Answers


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