Beispiel #1
0
    private RecipeUI AddRecipeToUI(RecipeBase.Recipe recipe)
    {
        if (RecipeIndex >= maxUIRecipes || RecipeIndex - 1 >= recipes.Count)
        {
            return(null);
        }
        RecipeIndex++;
        var obj = Instantiate(RecipeUI, new Vector3(0, 0, 0), Quaternion.identity);
        //bool isOnLeftPage = (RecipeIndex - 1 % 2) == 0;
        Transform parent = leftPage.transform;        //isOnLeftPage ? leftPage.transform : rightPage.transform;

        obj.transform.SetParent(parent);
        obj.transform.localScale = new Vector3(0.8f, 0.6f, 1);
        obj.transform.GetComponent <RectTransform>().anchoredPosition = new Vector3(42, 0, -10);
        RecipeCards.Add(obj);
        var src = obj.GetComponent <RecipeUI>();

        StartCoroutine(SetRecipeIcon(src.Photo, recipe.strMealThumb));
        src.text.text     = src.textShadow.text = recipe.strMeal.Substring(0, 1) + recipe.strMeal.Substring(1).ToLower();
        src.category.text = recipe.strCategory;
        src.cuisine.text  = recipe.strArea;
        CheckIngredients(recipe, src);
        RecipesInUI.Add(recipe);
        recipeInstructions.text = recipeSystem.FilterInstructions(ref recipe.strInstructions);
        return(src);
    }
Beispiel #2
0
 private void CheckIngredients(RecipeBase.Recipe recipe, RecipeUI src)
 {
     string[] ings = { recipe.strIngredient1, recipe.strIngredient2, recipe.strIngredient3, recipe.strIngredient4, recipe.strIngredient5, recipe.strIngredient6, recipe.strIngredient7, recipe.strIngredient8 };
     for (int i = 0; i < ings.Length; i++)
     {
         if (src.ingredientIMG.Length >= ings.Length && ings[i].Length <= 1)
         {
             DestroyImmediate(src.ingredientIMG[i].transform.parent.gameObject);
         }
     }
 }
Beispiel #3
0
 public static RecipeUI GenerateRecipeUI(RecipeBase.Recipe recipe)
 {
     return(self.AddRecipeToUI(recipe));
 }