Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7706987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:14:50+00:00 2026-06-01T00:14:50+00:00

I have this ingredients array which contains multiple variables (like name, icon, value etc.).

  • 0

I have this ingredients array which contains multiple variables (like name, icon, value etc.). When the player has surpassed certain points a new ingredient has to be added to that ingredients array. So I have an other array which contains icons and names for the new ingredients (values are to be added separately at runtime).

But the thing is you just can’t use Add to add new elements to the ingredients array (also tried to give both arrays the same variables), or just add an new element at the end and fill the elements separately.

Script for unlocking ingredients:

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class progressManager : MonoBehaviour {
    
    private int ingUnlockLevel;
    private int lockLevel = 0;
    private int newIngScore = 500;
    public List<ingUnlocks> ingUnlock = new List<ingUnlocks>();
    public List<GameObject> lockedCraft = new List<GameObject>();
    public Texture locks;
    public Texture normal;
    private bool upGrade;
    
    public TextMesh nextIngredient;
    // Update is called once per frame
    void Update () {
        
        nextIngredient.text = ingUnlock[lockLevel].name;
        
        ingUnlockLevel = GetComponent<gameMechanics>().headScore;
        
        if(ingUnlockLevel >= newIngScore){upGrade = true;}
        
        if(upGrade == true){    
            GetComponent<productManager>().ingredient.;
            newIngScore = newIngScore *2;
            lockLevel+=1; 
            upGrade = false;
        }
    }
    
    [System.Serializable]
    public class ingUnlocks{
        public string name;
        public Texture icon;
    }
}

And part of the script for the players ingredients:

using UnityEngine;
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

public class productManager : MonoBehaviour {

    private class ingredientComparer : IComparer<ingredients>{
        
        public int Compare(ingredients a, ingredients b)
        {
            return ((int) a.c2cPerc ) - ((int) b.c2cPerc);
        }
    }

        public List<ingredients> ingredient = new List<ingredients>();
}

[System.Serializable]
public class ingredients{
    
    public string name;
    public Texture icon;
    public int score;
    public int quantity;
    public float c2cPerc;
    public bool usable;
    
}

Is there any way to add a new name and icon from the unlocking array, to the players ingredient array?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T00:14:51+00:00Added an answer on June 1, 2026 at 12:14 am

    it’s hard to tell what you’re after exactly, but does this answer your question?:

    GetComponent<productManager>().ingredient.Add(new ingredients { name = ingUnlock[locklevel].name, icon = ingUnlock[locklevel].icon });
    

    PS: I just completed the line of code from your sample that wouldn’t compile and added a new ingredients item there, guessing this is what you wanted to do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Solr installation that contains recipes. Each recipe has multiple ingredients and
I have this JS code: var recipesPost = function(name, ingredients, steps) { $.post('/api/recipes', {
I have a Recipe model, which has Ingredients embedded in it, using Mongoid. class
I have an array of ingredients for soup as strings. These ingredients are also
I have a collection of recipes, each having a number of ingredients. This information
I have four tables: cuisines(id, name); recipes(id, cuisine_id, name, picture); ingredients(id, name); ingredients_recipes(ingredient_id, recipe_id);
I have a simple php structures. class Ingredient and class Ingredients, i have this
I have 3 tables with this structure: Recipe id | recipe_name Ingredients id |
I have an xml formatted document that looks like this: <?xml version=1.0 encoding=windows-1250?> <
I have this function in my controller: def showRecipeIngredients ingredients = RecipeIngredient.where( recipe_id =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.