IEnumerator BuildCategory(CustomizationCategoryView categoryView, string categoryId, IEnumerable <string> itemIds)
        {
            yield return(null);

            foreach (var itemId in itemIds)
            {
                yield return(CreateItemButton(categoryView, categoryId, itemId));
            }
        }
        IEnumerator CreateItemButton(CustomizationCategoryView categoryView, string categoryId, string itemId)
        {
            if (IsDataItemToInstantiateValid(categoryView, categoryId, itemId))
            {
                var itemButton = Object.Instantiate(categoryView.itemButtonPrefab, categoryView.transform);
                yield return(null);

                itemButton.Initialize(categoryId, itemId);
            }
        }
        static bool IsDataItemToInstantiateValid(CustomizationCategoryView categoryView, string categoryId,
                                                 string itemId)
        {
            bool isViewNull = categoryView == null;

            if (isViewNull || categoryView.itemButtonPrefab == null || categoryView.transform == null)
            {
                var baseError = string.Format("Customisation cant create item: {0} - {1}. One of elements is null\n",
                                              categoryId, itemId);
                var nullText = isViewNull
                    ? "categoryView is null"
                    : string.Format("categoryView.itemButtonPrefab - {0}, categoryView.transform - {1}",
                                    categoryView.itemButtonPrefab, categoryView.transform);
                Debug.LogErrorFormat(baseError + nullText);
                return(false);
            }

            return(true);
        }