Hey,
I'm struggling to figure out how to make a crafting menu with dynamic tabs for categories. The category tabs shown would depend on what crafting categories the Crafter has.
I have a custom crafting menu script with this as my SetCrafter function:
It works as far as it does instantiate proper tab prefabs, but clicking those tabs does nothing.
Cheers
I'm struggling to figure out how to make a crafting menu with dynamic tabs for categories. The category tabs shown would depend on what crafting categories the Crafter has.
I have a custom crafting menu script with this as my SetCrafter function:
Code:
public override void SetCrafter (Crafter crafter) {
m_Crafter = crafter;
m_Crafter.Initialize (false);
// Destroy old tabs
for (int i = 0; i < m_CraftingRecipeGrid.TabControl.m_Content.childCount; i++) {
Destroy (m_CraftingRecipeGrid.TabControl.m_Content.GetChild (i).gameObject);
}
// Create new tabs
for (int i = 0; i < m_Crafter.CraftingCategories.Length; i++) {
GameObject tab = Instantiate (CraftingCategoryTab);
tab.transform.SetParent (m_CraftingRecipeGrid.TabControl.m_Content, false);
CraftingTabData data = tab.GetComponent<CraftingTabData> ();
TabToggle toggle = tab.GetComponent<TabToggle> ();
data.CraftingCategory = m_Crafter.CraftingCategories [i];
toggle.SetText (m_Crafter.CraftingCategories [i].name);
}
m_CraftingRecipeGrid.TabControl.Initialize (true);
DrawRecipes ();
}
It works as far as it does instantiate proper tab prefabs, but clicking those tabs does nothing.
Cheers