< Summary

Class:CarouselComponentView
Assembly:UIComponents
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/UIComponents/Scripts/Components/Carousel/CarouselComponentView.cs
Covered lines:195
Uncovered lines:53
Coverable lines:248
Total lines:673
Line coverage:78.6% (195 of 248)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
CarouselComponentView()0%110100%
Awake()0%110100%
Start()0%220100%
Configure(...)0%110100%
RefreshControl()0%22090.91%
OnScreenSizeChanged()0%110100%
Dispose()0%110100%
SetSpaceBetweenItems(...)0%2.032080%
SetTimeBetweenItems(...)0%110100%
SetAnimationTransitionTime(...)0%110100%
SetAnimationCurve(...)0%110100%
SetBackgroundColor(...)0%2.262060%
SetManualControlsActive()0%2100%
SetManualControlsActive(...)0%6.076087.5%
SetItems(...)0%6200%
SetItems(...)0%220100%
AddItemWithDotsSelector(...)0%110100%
AddItem(...)0%110100%
RemoveItem(...)0%220100%
GetItems()0%110100%
ExtractItems()0%330100%
RemoveItems()0%110100%
StartCarousel(...)0%220100%
StopCarousel()0%220100%
GoToPreviousItem()0%2.062075%
ResetCarousel()0%2100%
GoToNextItem()0%2.062075%
MakeJumpFromDotsSelector(...)0%2.062075%
ConfigureManualButtonsEvents()0%330100%
CreateItem(...)0%2.012088.89%
ResizeItem(...)0%110100%
ResizeAllItems()0%5.935066.67%
DestroyInstantiatedItems()0%330100%
RunCarouselCoroutine()0%34.4618062.96%
RunRightAnimation()0%8.125050%
RunLeftAnimation()0%8.125050%
RunAnimationCoroutine()0%5.735069.23%
GenerateDotsSelector()0%660100%
SetSelectedDot(...)0%550100%
CleanInstantiatedItems()0%2100%
ResetManualCarousel()0%2100%
RegisterCurrentInstantiatedItems()0%6.026092.31%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/UIComponents/Scripts/Components/Carousel/CarouselComponentView.cs

#LineLine coverage
 1using DCL.Helpers;
 2using System.Collections;
 3using System.Collections.Generic;
 4using System.Linq;
 5using UnityEngine;
 6using UnityEngine.UI;
 7
 8public interface ICarouselComponentView
 9{
 10    /// <summary>
 11    /// Set the distance between carousel items.
 12    /// </summary>
 13    /// <param name="newSpace">Distance between items.</param>
 14    void SetSpaceBetweenItems(float newSpace);
 15
 16    /// <summary>
 17    /// Set the time that will be pass between carousel items.
 18    /// </summary>
 19    /// <param name="newTime">Time between items.</param>
 20    void SetTimeBetweenItems(float newTime);
 21
 22    /// <summary>
 23    /// Set the time that will be pass during the transition between items.
 24    /// </summary>
 25    /// <param name="newTime">Transition time between items.</param>
 26    void SetAnimationTransitionTime(float newTime);
 27
 28    /// <summary>
 29    /// Set the animation curve that will be used for the animation between items.
 30    /// </summary>
 31    /// <param name="newCurve">Animation curve between items.</param>
 32    void SetAnimationCurve(AnimationCurve newCurve);
 33
 34    /// <summary>
 35    /// Set the color of the carousel background.
 36    /// </summary>
 37    /// <param name="newColor">Background color.</param>
 38    void SetBackgroundColor(Color newColor);
 39
 40    /// <summary>
 41    /// Activates/Deactivates the controls to go to the next/previous item manually.
 42    /// </summary>
 43    /// <param name="isActived">True for activating the manual controls.</param>
 44    void SetManualControlsActive(bool isActived);
 45
 46    /// <summary>
 47    /// Set the items of the carousel.
 48    /// </summary>
 49    /// <param name="items">List of UI components.</param>
 50    void SetItems(List<BaseComponentView> items);
 51
 52    /// <summary>
 53    /// Creates the items of the carousel from the prefab. All previously existing items will be removed.
 54    /// </summary>
 55    /// <param name="prefab">Prefab to create items</param>
 56    /// <param name="amountOfItems">Amounts of items to be created</param>
 57    void SetItems(BaseComponentView prefab, int amountOfItems);
 58
 59    /// <summary>
 60    /// Adds a new item in the carousel.
 61    /// </summary>
 62    /// <param name="item">An UI component.</param>
 63    void AddItem(BaseComponentView item);
 64
 65    /// <summary>
 66    /// Adds a new item in the carousel and update carousel dot selector.
 67    /// </summary>
 68    /// <param name="item">An UI component.</param>
 69    void AddItemWithDotsSelector(BaseComponentView item);
 70
 71    /// <summary>
 72    /// Remove an item from the carousel.
 73    /// </summary>
 74    /// <param name="item">An UI component</param>
 75    void RemoveItem(BaseComponentView item);
 76
 77    /// <summary>
 78    /// Get all the items of the carousel.
 79    /// </summary>
 80    /// <returns>The list of items.</returns>
 81    List<BaseComponentView> GetItems();
 82
 83    /// <summary>
 84    /// Extract all items out of the carousel.
 85    /// </summary>
 86    /// <returns>The list of extracted items.</returns>
 87    List<BaseComponentView> ExtractItems();
 88
 89    /// <summary>
 90    /// Remove all existing items from the carousel.
 91    /// </summary>
 92    void RemoveItems();
 93
 94    /// <summary>
 95    /// Start carousel animation.
 96    /// </summary>
 97    /// <param name="fromIndex">It specifies from where item the carousel will start.</param>
 98    /// <param name="startInmediately">True to directly execute the first transition.</param>
 99    /// <param name="direction">Set the direction of the carousel animations: right or left.</param>
 100    /// <param name="changeDirectionAfterFirstTransition">True to change the carousel direction just after the first tra
 101    /// <param name="numberOfInitialJumps">Number of jumps that will be executed in the first transition.</param>
 102    void StartCarousel(int fromIndex, bool startInmediately, CarouselDirection direction, bool changeDirectionAfterFirst
 103
 104    /// <summary>
 105    /// Stop carousel animation.
 106    /// </summary>
 107    void StopCarousel();
 108
 109    /// <summary>
 110    /// Force the carousel to show the previous item.
 111    /// </summary>
 112    void GoToPreviousItem();
 113
 114    /// <summary>
 115    /// Force the carousel to show the next item.
 116    /// </summary>
 117    void GoToNextItem();
 118
 119    /// <summary>
 120    /// Force the carousel to jump to a specific item.
 121    /// </summary>
 122    /// <param name="numberOfJumps">Number of jumps that will be executed during the transition.</param>
 123    /// <param name="direction">Direction in which to make the jumps.</param>
 124    void MakeJumpFromDotsSelector(int numberOfJumps, CarouselDirection direction);
 125}
 126
 127public enum CarouselDirection
 128{
 129    Right,
 130    Left
 131}
 132
 133public class CarouselComponentView : BaseComponentView, ICarouselComponentView, IComponentModelConfig<CarouselComponentM
 134{
 135    [Header("Prefab References")]
 136    [SerializeField] internal RectTransform itemsContainer;
 137    [SerializeField] internal HorizontalLayoutGroup horizontalLayout;
 138    [SerializeField] internal ScrollRect itemsScroll;
 139    [SerializeField] internal RectTransform viewport;
 140    [SerializeField] internal Image background;
 141    [SerializeField] internal Button previousButton;
 142    [SerializeField] internal Button nextButton;
 143    [SerializeField] internal HorizontalLayoutGroup dotsSelector;
 144    [SerializeField] internal Button dotButtonTemplate;
 145    [SerializeField] internal Color dotSelectedColor;
 146    [SerializeField] internal Color dotUnselectedColor;
 147
 148    [Header("Configuration")]
 149    [SerializeField] internal CarouselComponentModel model;
 150
 149151    internal List<BaseComponentView> instantiatedItems = new List<BaseComponentView>();
 152    internal Coroutine itemsCoroutine;
 153    internal int currentItemIndex = 0;
 154    internal int currentDotIndex = 0;
 155    internal float currentFinalNormalizedPos;
 156    internal bool isInTransition = false;
 157
 158    public override void Awake()
 159    {
 142160        base.Awake();
 161
 142162        StartCoroutine(RegisterCurrentInstantiatedItems());
 142163        ConfigureManualButtonsEvents();
 142164    }
 165
 166    public override void Start()
 167    {
 73168        if (model.automaticTransition)
 73169            StartCarousel();
 73170    }
 171
 172    public void Configure(CarouselComponentModel newModel)
 173    {
 1174        model = newModel;
 1175        RefreshControl();
 1176    }
 177
 178    public override void RefreshControl()
 179    {
 1180        if (model == null)
 0181            return;
 182
 1183        SetSpaceBetweenItems(model.spaceBetweenItems);
 1184        SetTimeBetweenItems(model.timeBetweenItems);
 1185        SetAnimationTransitionTime(model.animationTransitionTime);
 1186        SetAnimationCurve(model.animationCurve);
 1187        SetBackgroundColor(model.backgroundColor);
 1188        SetManualControlsActive(model.showManualControls);
 1189        ResizeAllItems();
 1190        GenerateDotsSelector();
 1191    }
 192
 193    public override void OnScreenSizeChanged()
 194    {
 26195        base.OnScreenSizeChanged();
 196
 26197        ResizeAllItems();
 26198    }
 199
 200    public override void Dispose()
 201    {
 424202        base.Dispose();
 203
 424204        StopCarousel();
 424205        DestroyInstantiatedItems();
 424206    }
 207
 208    public void SetSpaceBetweenItems(float newSpace)
 209    {
 2210        model.spaceBetweenItems = newSpace;
 211
 2212        if (horizontalLayout == null)
 0213            return;
 214
 2215        horizontalLayout.spacing = newSpace;
 2216    }
 217
 4218    public void SetTimeBetweenItems(float newTime) { model.timeBetweenItems = newTime; }
 219
 4220    public void SetAnimationTransitionTime(float newTime) { model.animationTransitionTime = newTime; }
 221
 4222    public void SetAnimationCurve(AnimationCurve newCurve) { model.animationCurve = newCurve; }
 223
 224    public void SetBackgroundColor(Color newColor)
 225    {
 2226        model.backgroundColor = newColor;
 227
 2228        if (background == null)
 2229            return;
 230
 0231        background.color = newColor;
 0232    }
 233
 234    public void SetManualControlsActive() =>
 0235        SetManualControlsActive(model.showManualControls);
 236
 237    public void SetManualControlsActive(bool isActived)
 238    {
 738239        model.showManualControls = isActived;
 240
 738241        if (previousButton == null || nextButton == null)
 0242            return;
 243
 738244        int currentNumberOfItems = itemsContainer.childCount;
 738245        previousButton.gameObject.SetActive(isActived && currentNumberOfItems > 1);
 738246        nextButton.gameObject.SetActive(isActived && currentNumberOfItems > 1);
 738247        dotsSelector.gameObject.SetActive(isActived && currentNumberOfItems > 1);
 738248    }
 249
 250    public void SetItems(BaseComponentView prefab, int amountOfItems)
 251    {
 0252        DestroyInstantiatedItems();
 253
 0254        for (int i = 0; i < amountOfItems; i++)
 255        {
 0256            BaseComponentView instanciatedItem = Instantiate(prefab);
 0257            CreateItem(instanciatedItem, $"Item{i}");
 258        }
 259
 0260        SetManualControlsActive(model.showManualControls);
 0261        GenerateDotsSelector();
 0262    }
 263
 264    public void SetItems(List<BaseComponentView> items)
 265    {
 15266        DestroyInstantiatedItems();
 267
 92268        for (int i = 0; i < items.Count; i++)
 269        {
 31270            CreateItem(items[i], $"Item{i}");
 271        }
 272
 15273        SetManualControlsActive(model.showManualControls);
 15274        GenerateDotsSelector();
 15275    }
 276
 277    public void AddItemWithDotsSelector(BaseComponentView item)
 278    {
 2279        CreateItem(item, $"Item{instantiatedItems.Count}");
 2280        SetManualControlsActive(model.showManualControls);
 2281        GenerateDotsSelector();
 2282    }
 283
 284    public void AddItem(BaseComponentView item) =>
 6285        CreateItem(item, $"Item{instantiatedItems.Count}");
 286
 287    public void RemoveItem(BaseComponentView item)
 288    {
 2289        BaseComponentView itemToRemove = instantiatedItems.FirstOrDefault(x => x == item);
 1290        if (itemToRemove != null)
 291        {
 1292            Destroy(itemToRemove.gameObject);
 1293            instantiatedItems.Remove(item);
 294        }
 295
 1296        SetManualControlsActive(model.showManualControls);
 1297        GenerateDotsSelector();
 1298    }
 299
 1300    public List<BaseComponentView> GetItems() { return instantiatedItems; }
 301
 302    public List<BaseComponentView> ExtractItems()
 303    {
 590304        List<BaseComponentView> extractedItems = new List<BaseComponentView>();
 1730305        foreach (BaseComponentView item in instantiatedItems)
 306        {
 275307            if (item != null)
 275308                item.transform.SetParent(null);
 309
 275310            extractedItems.Add(item);
 311        }
 312
 590313        instantiatedItems.Clear();
 590314        SetManualControlsActive(model.showManualControls);
 315
 590316        return extractedItems;
 317    }
 318
 319    public void RemoveItems()
 320    {
 110321        DestroyInstantiatedItems();
 110322        SetManualControlsActive(model.showManualControls);
 110323    }
 324
 325    public void StartCarousel(
 326        int fromIndex = 0,
 327        bool startInmediately = false,
 328        CarouselDirection direction = CarouselDirection.Right,
 329        bool changeDirectionAfterFirstTransition = false,
 330        int numberOfInitialJumps = 1)
 331    {
 123332        StopCarousel();
 333
 123334        if (isActiveAndEnabled)
 123335            itemsCoroutine = StartCoroutine(RunCarouselCoroutine(fromIndex, startInmediately, direction, changeDirection
 123336    }
 337
 338    public void StopCarousel()
 339    {
 548340        if (itemsCoroutine == null)
 542341            return;
 342
 6343        StopCoroutine(itemsCoroutine);
 344
 6345        itemsCoroutine = null;
 6346        isInTransition = false;
 6347    }
 348
 349    public void GoToPreviousItem()
 350    {
 2351        if (isInTransition)
 0352            return;
 353
 2354        StartCarousel(
 355            fromIndex: currentItemIndex,
 356            startInmediately: true,
 357            direction: CarouselDirection.Left,
 358            changeDirectionAfterFirstTransition: true,
 359            numberOfInitialJumps: 1);
 2360    }
 361
 362    public void ResetCarousel()
 363    {
 0364        int index = 0;
 0365        SetSelectedDot(index);
 0366    }
 367
 368    public void GoToNextItem()
 369    {
 2370        if (isInTransition)
 0371            return;
 372
 2373        StartCarousel(
 374            fromIndex: currentItemIndex,
 375            startInmediately: true,
 376            direction: CarouselDirection.Right,
 377            changeDirectionAfterFirstTransition: false,
 378            numberOfInitialJumps: 1);
 2379    }
 380
 381    public void MakeJumpFromDotsSelector(int numberOfJumps, CarouselDirection direction)
 382    {
 1383        if (isInTransition)
 0384            return;
 385
 1386        StartCarousel(
 387            fromIndex: currentItemIndex,
 388            startInmediately: true,
 389            direction: direction,
 390            changeDirectionAfterFirstTransition: direction == CarouselDirection.Left,
 391            numberOfInitialJumps: numberOfJumps);
 1392    }
 393
 394    internal void ConfigureManualButtonsEvents()
 395    {
 144396        if (previousButton != null)
 397        {
 144398            previousButton.onClick.RemoveAllListeners();
 144399            previousButton.onClick.AddListener(GoToPreviousItem);
 400        }
 401
 144402        if (nextButton != null)
 403        {
 144404            nextButton.onClick.RemoveAllListeners();
 144405            nextButton.onClick.AddListener(GoToNextItem);
 406        }
 144407    }
 408
 409    internal void CreateItem(BaseComponentView newItem, string name)
 410    {
 40411        if (newItem == null)
 0412            return;
 413
 40414        newItem.transform.SetParent(itemsContainer);
 40415        newItem.transform.localPosition = Vector3.zero;
 40416        newItem.transform.localScale = Vector3.one;
 40417        newItem.name = name;
 418
 40419        instantiatedItems.Add(newItem);
 420
 40421        ResizeItem((RectTransform)newItem.transform);
 40422    }
 423
 424    internal void ResizeItem(RectTransform item)
 425    {
 40426        ((RectTransform)item.transform).sizeDelta = new Vector2(viewport.rect.width, viewport.rect.height);
 427
 40428        int currentNumberOfItems = itemsContainer.childCount;
 40429        itemsContainer.offsetMin = Vector2.zero;
 40430        float extraSpace = (currentNumberOfItems - 1) * model.spaceBetweenItems;
 40431        itemsContainer.offsetMax = new Vector2(viewport.rect.width * (currentNumberOfItems - 1) + extraSpace, 0);
 40432    }
 433
 434    internal void ResizeAllItems()
 435    {
 44436        if (itemsScroll.horizontalNormalizedPosition != 0f)
 0437            itemsScroll.horizontalNormalizedPosition = 0f;
 438
 44439        if (model.automaticTransition)
 44440            StartCarousel();
 441
 88442        foreach (Transform child in itemsContainer)
 443        {
 0444            ResizeItem((RectTransform)child);
 445        }
 44446    }
 447
 448    internal void DestroyInstantiatedItems()
 449    {
 549450        List<BaseComponentView> itemsToDestroy = ExtractItems();
 451
 1632452        foreach (BaseComponentView itemToDestroy in itemsToDestroy)
 453        {
 267454            if (itemToDestroy != null)
 267455                DestroyImmediate(itemToDestroy.gameObject);
 456        }
 457
 549458        itemsToDestroy.Clear();
 459
 549460        instantiatedItems.Clear();
 461
 549462        itemsContainer.offsetMin = Vector2.zero;
 549463        itemsContainer.offsetMax = Vector2.zero;
 549464    }
 465
 466    internal IEnumerator RunCarouselCoroutine(
 467        int fromIndex = 0,
 468        bool startInmediately = false,
 469        CarouselDirection direction = CarouselDirection.Right,
 470        bool changeDirectionAfterFirstTransition = false,
 471        int numberOfInitialJumps = 1)
 472    {
 123473        currentItemIndex = fromIndex;
 123474        SetSelectedDot(currentItemIndex);
 123475        bool continueCarrousel = true;
 123476        while (gameObject.activeInHierarchy && itemsContainer.childCount > 1 && continueCarrousel)
 477        {
 6478            float elapsedTime = 0f;
 479
 6480            if (!startInmediately)
 481            {
 1482                while (elapsedTime < model.timeBetweenItems)
 483                {
 1484                    if (!model.pauseOnFocus || (model.pauseOnFocus && !isFocused))
 1485                        elapsedTime += Time.deltaTime;
 486
 1487                    yield return null;
 488                }
 489
 490            }
 491
 5492            if (instantiatedItems.Count > 0)
 493            {
 5494                if (direction == CarouselDirection.Right)
 495                {
 3496                    SetSelectedDot(currentItemIndex == (instantiatedItems.Count - 1) ? 0 : currentItemIndex + numberOfIn
 3497                    yield return RunRightAnimation(numberOfInitialJumps);
 498
 0499                    if (changeDirectionAfterFirstTransition)
 500                    {
 0501                        direction = CarouselDirection.Left;
 0502                        changeDirectionAfterFirstTransition = false;
 503                    }
 0504                    continueCarrousel = model.automaticTransition;
 505                }
 506                else
 507                {
 2508                    SetSelectedDot(currentItemIndex == 0 ? (instantiatedItems.Count - 1) : currentItemIndex - numberOfIn
 2509                    yield return RunLeftAnimation(numberOfInitialJumps);
 510
 0511                    if (changeDirectionAfterFirstTransition)
 512                    {
 0513                        direction = CarouselDirection.Right;
 0514                        changeDirectionAfterFirstTransition = false;
 515                    }
 0516                    continueCarrousel = model.automaticTransition;
 517                }
 518            }
 519
 0520            startInmediately = false;
 0521            numberOfInitialJumps = 1;
 522        }
 117523    }
 524
 525    internal IEnumerator RunRightAnimation(int numberOfJumps = 1)
 526    {
 3527        if (currentItemIndex == instantiatedItems.Count - 1)
 528        {
 0529            currentItemIndex = 0;
 0530            yield return RunAnimationCoroutine(CarouselDirection.Left, instantiatedItems.Count - 1);
 531        }
 532        else
 533        {
 3534            currentItemIndex += numberOfJumps;
 3535            yield return RunAnimationCoroutine(CarouselDirection.Right, numberOfJumps);
 536        }
 0537    }
 538
 539    internal IEnumerator RunLeftAnimation(int numberOfJumps = 1)
 540    {
 2541        if (currentItemIndex == 0)
 542        {
 2543            currentItemIndex = instantiatedItems.Count - 1;
 2544            yield return RunAnimationCoroutine(CarouselDirection.Right, instantiatedItems.Count - 1);
 545        }
 546        else
 547        {
 0548            currentItemIndex -= numberOfJumps;
 0549            yield return RunAnimationCoroutine(CarouselDirection.Left, numberOfJumps);
 550        }
 0551    }
 552
 553    internal IEnumerator RunAnimationCoroutine(CarouselDirection direction, int numberOfJumps = 1)
 554    {
 5555        isInTransition = true;
 5556        float currentAnimationTime = 0f;
 5557        float initialNormalizedPos = itemsScroll.horizontalNormalizedPosition;
 558
 5559        if (direction == CarouselDirection.Right)
 5560            currentFinalNormalizedPos = initialNormalizedPos + ((float)numberOfJumps / (instantiatedItems.Count - 1));
 561        else
 0562            currentFinalNormalizedPos = initialNormalizedPos - ((float)numberOfJumps / (instantiatedItems.Count - 1));
 563
 5564        while (currentAnimationTime <= model.animationTransitionTime)
 565        {
 5566            itemsScroll.horizontalNormalizedPosition = Mathf.Clamp01(Mathf.Lerp(
 567                initialNormalizedPos,
 568                currentFinalNormalizedPos,
 569                model.animationCurve.Evaluate(currentAnimationTime / model.animationTransitionTime)));
 570
 5571            currentAnimationTime += Time.deltaTime;
 572
 5573            yield return null;
 574        }
 575
 0576        itemsScroll.horizontalNormalizedPosition = currentFinalNormalizedPos;
 0577        isInTransition = false;
 0578    }
 579
 580    public void GenerateDotsSelector()
 581    {
 38582        List<GameObject> dotsToRemove = new List<GameObject>();
 226583        foreach (Transform child in dotsSelector.transform)
 584        {
 75585            if (child.gameObject == dotButtonTemplate.gameObject)
 586                continue;
 587
 37588            dotsToRemove.Add(child.gameObject);
 589        }
 590
 150591        foreach (GameObject dotToRemove in dotsToRemove)
 592        {
 37593            Utils.SafeDestroy(dotToRemove);
 594        }
 595
 152596        for (int i = 0; i < itemsContainer.childCount; i++)
 597        {
 38598            Button newDotButton = Instantiate(dotButtonTemplate, dotsSelector.transform);
 38599            newDotButton.gameObject.SetActive(true);
 38600            newDotButton.onClick.AddListener(() =>
 601            {
 0602                int dotButtonIndex = newDotButton.transform.GetSiblingIndex() - 1;
 0603                if (dotButtonIndex != currentDotIndex)
 604                {
 0605                    MakeJumpFromDotsSelector(
 606                        Mathf.Abs(dotButtonIndex - currentDotIndex),
 607                        dotButtonIndex > currentDotIndex ? CarouselDirection.Right : CarouselDirection.Left);
 608                }
 0609            });
 610        }
 611
 38612        SetSelectedDot(0);
 38613    }
 614
 615    internal void SetSelectedDot(int index)
 616    {
 167617        int currentIndex = 0;
 167618        currentDotIndex = -1;
 1282619        foreach (Transform child in dotsSelector.transform)
 620        {
 474621            if (child.gameObject == dotButtonTemplate.gameObject)
 622                continue;
 623
 307624            if (currentIndex == index)
 625            {
 144626                child.GetComponent<Image>().color = dotSelectedColor;
 144627                child.transform.localScale = Vector3.one * 1.5f;
 144628                currentDotIndex = index;
 629            }
 630            else
 631            {
 163632                child.GetComponent<Image>().color = dotUnselectedColor;
 163633                child.transform.localScale = Vector3.one;
 634            }
 635
 307636            currentIndex++;
 637        }
 167638    }
 639
 640    public void CleanInstantiatedItems()
 641    {
 0642        instantiatedItems = new List<BaseComponentView>();
 0643    }
 644
 645    public void ResetManualCarousel()
 646    {
 0647        isInTransition = false;
 0648        currentItemIndex = 0;
 0649        SetSelectedDot(0);
 0650    }
 651
 652    internal IEnumerator RegisterCurrentInstantiatedItems()
 653    {
 142654        instantiatedItems.Clear();
 655
 756656        foreach (Transform child in itemsContainer)
 657        {
 236658            BaseComponentView existingItem = child.GetComponent<BaseComponentView>();
 236659            if (existingItem != null)
 236660                instantiatedItems.Add(existingItem);
 661            else
 0662                Destroy(child.gameObject);
 663        }
 664
 665        // In the first loading, before calculating the size of the current items, it is needed to wait for a frame in o
 666        // allow time for the carousel viewport to get its final size to be able to execute the 'ResizeAllItems' functio
 142667        yield return null;
 668
 17669        ResizeAllItems();
 17670        SetManualControlsActive(model.showManualControls);
 17671        GenerateDotsSelector();
 17672    }
 673}