Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Anxo · Jul 15, 2011 at 09:24 PM · c#gamecenter

Prime 31 Game Center - C# question

Hi Unity Community, or should I say.. Hi Eric...

So I downloaded Prime 31's Game Center plugin. It would great but the hole thing is in C# and I learned JavaScript or as We would say "Unity Script" from tutorials to create games.

Game Center Manager file has an event that is fired when someone logs in

// Fired when a player is logged in

 public static event GameCenterEventHandler playerAuthenticated;

Problem I have is that I dont really know what an event is. I would like for it to trigger.. lets say a Debug.Log. But it does not work like a function

 public static event GamecenterEventHandler playerAuthenticated(){
     Debug.Log("player logged in");
 }

What I am trying to do is use this to check if the person logged in or not and make the appropriate buttons available by turning booleans off and on.

Comment
Add comment · Show 2
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 Herman-Tulleken · Jul 16, 2011 at 05:31 PM 0
Share

Can you please format your code?

avatar image synapsemassage · Jul 17, 2011 at 09:13 AM 0
Share

@Herman Tullekan A better question would be: "Why does QATO doesn't support the tabulator key for code formatting?" Answer:"It's a website where you jump from field to field with the tab key". This means QATO's textfields lack a basic functionality for code formatting, and that makes formatting quite inconvenient. In addition the textfield is not expandable which breaks long code lines thus distorting overview and making formatting even more inconvenient. Formatting should be a no-brainer but is a PIA withs QATO's code formatting feature. As long this is not fixed asking users for correct code formatting is kind of unfair. It's better to ask QATO for better code formatting implementation.

2 Replies

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

Answer by GuyTidhar · Jul 15, 2011 at 09:37 PM

You need to be registered to an event in order to respond to it.

For that you define a function of the type of the event and register it.

You need to know if GameCenterEventHandler takes arguments or not and according to that you can define your handlers.

For instance: If GameCenterEventHandler takes no arguments and function without arguments can be registered to handle it:

 public static void OnPlayerAuthenticated()
 {
    Debug.Log("player logged in");
 }

And you register like this:

 void Start()
 {
    playerAuthenticated += OnPlayerAuthenticated;
 }
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 Anxo · Jul 16, 2011 at 12:26 PM 0
Share

I have not been able to get this to work but I think this is the right answer. I used your code and did not get an error but when I tried to use the same code for another even that only had a different name. I got a group method conversion error or something.

I am sure your answer is right I just need to look into it more to understand it better. Thank you.

avatar image
0

Answer by synapsemassage · Jul 15, 2011 at 09:44 PM

 function Awake ()
 {
 GameCenterManager.playerAuthenticated += myPlayerIsAuthenticatedMethod;
 }

"myPlayerIsAuthenticatedMethod" is your function ( e.g. your button functionality) going to be executed when event occurs. You should also kill the eventlistener when loading new scene or then you don't need it anymore. For example:

  function OnDisable ()
     {
     GameCenterManager.playerAuthenticated -= myPlayerIsAuthenticatedMethod;
     }
 

Checkout out the examples coming with the plugin, although Prime31 examples are C# you will find usefull info how to use it also the forum thread is quiote useful. Use this Unitysearch (http://www.google.com/cse/home?cx=001712401338047450041%3Acsfhqk-trfa) to find answer.

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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

iOS Game Center Achievements Not Working 1 Answer

Renderer on object disabled after level reload 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