#it tells the prefab where to go
1 messages · Page 1 of 1 (latest)
okay, so it stores a Transform, doesn't actually set the parent of its own transform
got it
so, this should create two buttons and parent them to two different places
??
this code.
GameObject recipeButton = Instantiate(recipeUiButton, recipeButtonParent);
RecipeButton recipeButtonComponent = recipeButton.GetComponent<RecipeButton>();
recipeButtonComponent.ConfigureButton(recipe);
recipeButtonComponent.SetParent(recipesParent);
// Déterminez le parent en fonction de la catégorie
Transform categoryParent = GetCategoryParent(recipe.categoryName);
recipeButton.transform.SetParent(categoryParent);
recipeButtons.Add(recipe, recipeButton);
GameObject recipeButton2 = Instantiate(recipeUiButton, recipeButtonParent);
RecipeButton recipeButtonComponent2 = recipeButton2.GetComponent<RecipeButton>();
recipeButtonComponent2.ConfigureButton(recipe);
recipeButtonComponent2.SetParent(recipesParent);
// Déterminez le parent en fonction de la catégorie
Transform categoryParent2 = GetCategoryParent(CategoryName.All);
recipeButton2.transform.SetParent(categoryParent2);
recipeButtons.Add(recipe, recipeButton2);
it creates a button and parents it to the specific category parent
then it creates another button and parents it to the "all" category parent
i have this error
ArgumentException: An item with the same key has already been added. Key: AxeRecipe (RecipeData) System.Collections.Generic.Dictionary2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <391154401d904e0ca279fe00c621b01b>:0)
System.Collections.Generic.Dictionary2[TKey,TValue].Add (TKey key, TValue value) (at <391154401d904e0ca279fe00c621b01b>:0) CraftingSystem.UpdateDisplayedRecipes () (at Assets/Scripts/Crafting/CraftingSystem.cs:112) CraftingSystem.Update () (at Assets/Scripts/Crafting/CraftingSystem.cs:73)
well, now you have two buttons for the same recipe
so your dictionary already has that recipe as a key
do you ever actually use the dictionary to get a button from its recipe?
I only see you using recipeButtons in the method that removes all buttons
I use it just for recipeButtons
if it's only used to keep a list of buttons, you can just make it a list
yes it works
I have another question
is it possible that when you open the menu, it shows the All category as selected?
do you have a way to change which category is shown?
thats my code for the category
Do you have an idea
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Do you have an idea ?
@spiral glacier when I craft an item, it duplicates the buttons
??