Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Number collected vs total number to be collected by category

Discussion in 'Scripting' started by marplast, Jun 21, 2020.

  1. marplast

    marplast

    Joined:
    Jun 21, 2020
    Posts:
    15
    I have several categories of resources which I want the player to collect. I have used Enum to name the categories and Dictionary to keep track of the number of resources collected in each category.

    I also want to introduce a goal which is the total number that needs to be collected for each category and I am unsure as to the best way to keep track of this. I would like this second number to be serializable in the inspector so that it can be changed for different levels.

    So, ideally I need a structure such as category name, followed by a [serializefield] total number to be collected, followed by the actual number collected.

    Any solutions? Much appreciated.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,971
    Yes, searching just now I see over 66 million possible solutions! Have you tried any of those yet?

    Screen Shot 2020-06-21 at 1.17.46 PM.png
     
  3. marplast

    marplast

    Joined:
    Jun 21, 2020
    Posts:
    15
    Thanks for replying Kurt. I know how to collect the items and display the number collected. I was just wondering how to incorporate a variable goal for each item which I can change in different levels. I will keep checking the videos, hopefully one of them can point me in the right direction.