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 robounited · Dec 19, 2012 at 11:39 AM · menunotificationsachievements

how do i do an achievements screen?

in my game level i have 2 scripts that show notifications in game when i collect objects for the achievements.

in the main menu i want a screen that shows the achievements locked until the notification shows in the level.

how do i do this and will this be affected by the fact that when i go back to the main menu the level starts over again losing what i had previously collected.

this is my 2 achievements scripts:

file 1:

 var state:int = 0;
 var scrollSpeed:float = 250;
 var showAchievementTime:float = 5;
 
 private var targetX:float;
 private var outOfScreenX:float;
 private var guitex:GUITexture;
 var edgeMargin:float;
 
 function Start(){
     guitex = GetComponent(GUITexture);
     outOfScreenX = guitex.pixelInset.x;
     targetX = Screen.width - guitex.texture.width - edgeMargin;
     
     yield WaitForSeconds(showAchievementTime);
     state = 1;
     yield WaitForSeconds(showAchievementTime);
     Destroy(gameObject);
 }
 
 function Update () {
     if(state == 0){
         guitex.pixelInset.x = Mathf.MoveTowards(guitex.pixelInset.x, targetX, scrollSpeed * Time.deltaTime);
     }
     else{
         guitex.pixelInset.x = Mathf.MoveTowards(guitex.pixelInset.x, outOfScreenX, scrollSpeed * Time.deltaTime);
     }
 }

File 2:

 var FirstKeyTex:Texture;
 var FifthKeyTex:Texture;
 var TenthKeyTex:Texture;
 var FirstStepTex:Texture;
 
 private var firstStepTaken:boolean;
 private var keys:int;
 var edgeMargin;
 
 function Start(){
     edgeMargin = Screen.width * .01;
 }
 
 function playerMoved(){
     if(!firstStepTaken){
         unlockAchievement(FirstStepTex);
         firstStepTaken = true;
     }
 }
 
 function pickedUpKey(){
     keys++;
     switch(keys){
         case 1: unlockAchievement(FirstKeyTex); break;
         case 5: unlockAchievement(FifthKeyTex); break;
         case 10: unlockAchievement(TenthKeyTex); break;
     }
 }
 
 function unlockAchievement(achievementTex:Texture){
     var go:GameObject = new GameObject("Achievement Object");
     go.transform.position = Vector3(0,0,Time.time);
     go.transform.localScale = Vector3(0,0,0);
     var guitex:GUITexture = go.AddComponent(GUITexture);
     guitex.texture = achievementTex;
     guitex.pixelInset.width = achievementTex.width;
     guitex.pixelInset.height = achievementTex.height;
     guitex.pixelInset.x = Screen.width * 1.1;
     guitex.pixelInset.y = Screen.height - achievementTex.height - edgeMargin;
     var achievementScript:AchievementScript = go.AddComponent(AchievementScript);
     achievementScript.edgeMargin = edgeMargin;
 }
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
1

Answer by SwarmConnect · Dec 20, 2012 at 02:52 AM

If you're looking for a simple solution for implementing achievements, there are a couple of good Unity Plugins out there that can help make this a ton easier. If you're looking to export your game to Android, then the Swarm (aka SwarmConnect) plugin is a good choice. Here's a link to it in the Unity asset store: Swarm Unity Plugin. If you need something for iOS, then there's the Prime 31 GameCenter plugin for that.

I hope these help make your life easier :).

I think there are a couple other achievement plugins out there as well (try searching the Unity Asset Store for "achievements") and by all means choose which ever one seems simplest and easiest for your situation.

I realize that the answer provided above may very well be a secondary solution to the issue you're having, but in the long run it very well might save you time, headache, and hassle.

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 robounited · Dec 20, 2012 at 10:47 AM 0
Share

ye, thanks although im looking for somethings thats free for windows. all i need is some code that calls the event from the script above to change an image really.

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

What are the notification animations called when user scores? 1 Answer

menu Visibility trigger ??? 0 Answers

GUI menu how to make a list in a list. C# 1 Answer

Menu gui with background image 0 Answers

D-pad navigate menu ?? 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