• 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
Question by $$anonymous$$ · Apr 03, 2019 at 02:13 PM · levelstars

Level stars on levels menu

Hi!

I want to see the number of stars in the level below every world.

Besides the victory panel, I want to dynamically locate the results of the stars on the levels.

When I win the first level , the same number of stars are shown below the numbers of all the levels.

I want to dynamically see the number of stars in each level

Comment

People who like this

0 Show 0
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
Best Answer

Answer by cs120319992 · Apr 05, 2019 at 11:02 AM

Create array int[] levelStars = new int[10]; // 10 levels with 0 stars

Suppose that 0 - 0 stars, 1 - 1 star, 2 - 2 stars, 3 - 3 stars.

When you pass the level with id = 3, change levelStars[id] = stars count and save it. And in menu load it

Comment

People who like this

0 Show 2 · 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 $$anonymous$$ · Apr 05, 2019 at 06:02 PM 0
Share

I do not understand how to do it

please bring an example

avatar image cs120319992 $$anonymous$$ · Apr 10, 2019 at 01:31 PM 0
Share
 using System;
 using System.Collections;
 using System.Collections.Generic;
 
 // Script that contains data of levels
 public class Levels : Monobehaviour {
     
     public int[] levelStatus = new int[10]; // Total 10 levels (or use inspector)
     /** Let's pretend that 
     * if levelStatus[0] == -1 { level is closed }
     * if levelStatus[0] == 0 { level is not passed or opened  }
     * if levelStatus[0] == 1 { level is passed on 1 star }
     * if levelStatus[0] == 2 { level is passed on 2 stars }
     * if levelStatus[0] == 3 { level is passed on 3 stars }
     */
     
     public void LevelOpen(int id) {
         levelStatus[id] = 0;
         
         Save();
     }
     
     public void LevelPassed(int id, int stars) {
         levelStats[id] = stars;
         
         Save();
     }
     
     private void Save() {
      // Save   
     }
     
     private void Load() {
         
     }
 }
 
 // Script that contains data of current level
 public class Levels : Monobehaviour {
     
     int id = 0; // Level first
     float time = 5;
     
     Levels levels;
     
     private Update() {
         time -= Time.deltaTime;
     }
     
     // When you win
     public void LevelPassed() {
         if(time > 4) {
             levels.levelStatus[id] = 3; // 3 stars
         } else
         if(time > 3) {
             levels.levelStatus[id] = 2; // 2 stars
         } else
         if(time > 1) {
             levels.levelStatus[id] = 1; // 1 stars
         } else
         if(time > 0) {
             levels.levelStatus[id] = 0; // 0 stars
         }
         
     }
     
 }

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

103 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why this middle code doesnt want to run, Playerpref problem 0 Answers

Photon JoinRandomRoom customGameProperties? Load proper scene 0 Answers

How to save a level that was randomly generated, so it can be returned to later. 1 Answer

What is the best way to navigate through a grid based level using Raycasting ? 2 Answers

Loading back and forth between levels, creates clone of player 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