< Summary

Class:CarouselComponentView
Assembly:UIComponents
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/UIComponents/Scripts/Components/Carousel/CarouselComponentView.cs
Covered lines:192
Uncovered lines:54
Coverable lines:246
Total lines:663
Line coverage:78% (192 of 246)
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%2100%
SetAnimationTransitionTime(...)0%2100%
SetAnimationCurve(...)0%2100%
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%2100%
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%37.6518060.71%
RunRightAnimation()0%9.665042.86%
RunLeftAnimation()0%9.665042.86%
RunAnimationCoroutine()0%5.735069.23%
GenerateDotsSelector()0%660100%
SetSelectedDot(...)0%550100%
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
 164151    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    {
 156160        base.Awake();
 161
 156162        StartCoroutine(RegisterCurrentInstantiatedItems());
 156163        ConfigureManualButtonsEvents();
 156164    }
 165
 166    public override void Start()
 167    {
 87168        if (model.automaticTransition)
 83169            StartCarousel();
 87170    }
 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    {
 458202        base.Dispose();
 203
 458204        StopCarousel();
 458205        DestroyInstantiatedItems();
 458206    }
 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
 0218    public void SetTimeBetweenItems(float newTime) { model.timeBetweenItems = newTime; }
 219
 0220    public void SetAnimationTransitionTime(float newTime) { model.animationTransitionTime = newTime; }
 221
 0222    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    {
 792239        model.showManualControls = isActived;
 240
 792241        if (previousButton == null || nextButton == null)
 0242            return;
 243
 792244        int currentNumberOfItems = itemsContainer.childCount;
 792245        previousButton.gameObject.SetActive(isActived && currentNumberOfItems > 1);
 792246        nextButton.gameObject.SetActive(isActived && currentNumberOfItems > 1);
 792247        dotsSelector.gameObject.SetActive(isActived && currentNumberOfItems > 1);
 792248    }
 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
 0300    public List<BaseComponentView> GetItems() { return instantiatedItems; }
 301
 302    public List<BaseComponentView> ExtractItems()
 303    {
 634304        List<BaseComponentView> extractedItems = new List<BaseComponentView>();
 1874305        foreach (BaseComponentView item in instantiatedItems)
 306        {
 303307            if (item != null)
 303308                item.transform.SetParent(null);
 309
 303310            extractedItems.Add(item);
 311        }
 312
 634313        instantiatedItems.Clear();
 634314        SetManualControlsActive(model.showManualControls);
 315
 634316        return extractedItems;
 317    }
 318
 319    public void RemoveItems()
 320    {
 120321        DestroyInstantiatedItems();
 120322        SetManualControlsActive(model.showManualControls);
 120323    }
 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    {
 137332        StopCarousel();
 333
 137334        if (isActiveAndEnabled)
 137335            itemsCoroutine = StartCoroutine(RunCarouselCoroutine(fromIndex, startInmediately, direction, changeDirection
 137336    }
 337
 338    public void StopCarousel()
 339    {
 596340        if (itemsCoroutine == null)
 586341            return;
 342
 10343        StopCoroutine(itemsCoroutine);
 344
 10345        itemsCoroutine = null;
 10346        isInTransition = false;
 10347    }
 348
 349    public void GoToPreviousItem()
 350    {
 3351        if (isInTransition)
 0352            return;
 353
 3354        StartCarousel(
 355            fromIndex: currentItemIndex,
 356            startInmediately: true,
 357            direction: CarouselDirection.Left,
 358            changeDirectionAfterFirstTransition: true,
 359            numberOfInitialJumps: 1);
 3360    }
 361
 362    public void ResetCarousel()
 363    {
 0364        int index = 0;
 0365        SetSelectedDot(index);
 366
 0367    }
 368
 369    public void GoToNextItem()
 370    {
 5371        if (isInTransition)
 0372            return;
 373
 5374        StartCarousel(
 375            fromIndex: currentItemIndex,
 376            startInmediately: true,
 377            direction: CarouselDirection.Right,
 378            changeDirectionAfterFirstTransition: false,
 379            numberOfInitialJumps: 1);
 5380    }
 381
 382    public void MakeJumpFromDotsSelector(int numberOfJumps, CarouselDirection direction)
 383    {
 1384        if (isInTransition)
 0385            return;
 386
 1387        StartCarousel(
 388            fromIndex: currentItemIndex,
 389            startInmediately: true,
 390            direction: direction,
 391            changeDirectionAfterFirstTransition: direction == CarouselDirection.Left,
 392            numberOfInitialJumps: numberOfJumps);
 1393    }
 394
 395    internal void ConfigureManualButtonsEvents()
 396    {
 158397        if (previousButton != null)
 398        {
 158399            previousButton.onClick.RemoveAllListeners();
 158400            previousButton.onClick.AddListener(GoToPreviousItem);
 401        }
 402
 158403        if (nextButton != null)
 404        {
 158405            nextButton.onClick.RemoveAllListeners();
 158406            nextButton.onClick.AddListener(GoToNextItem);
 407        }
 158408    }
 409
 410    internal void CreateItem(BaseComponentView newItem, string name)
 411    {
 40412        if (newItem == null)
 0413            return;
 414
 40415        newItem.transform.SetParent(itemsContainer);
 40416        newItem.transform.localPosition = Vector3.zero;
 40417        newItem.transform.localScale = Vector3.one;
 40418        newItem.name = name;
 419
 40420        instantiatedItems.Add(newItem);
 421
 40422        ResizeItem((RectTransform)newItem.transform);
 40423    }
 424
 425    internal void ResizeItem(RectTransform item)
 426    {
 40427        ((RectTransform)item.transform).sizeDelta = new Vector2(viewport.rect.width, viewport.rect.height);
 428
 40429        int currentNumberOfItems = itemsContainer.childCount;
 40430        itemsContainer.offsetMin = Vector2.zero;
 40431        float extraSpace = (currentNumberOfItems - 1) * model.spaceBetweenItems;
 40432        itemsContainer.offsetMax = new Vector2(viewport.rect.width * (currentNumberOfItems - 1) + extraSpace, 0);
 40433    }
 434
 435    internal void ResizeAllItems()
 436    {
 44437        if (itemsScroll.horizontalNormalizedPosition != 0f)
 0438            itemsScroll.horizontalNormalizedPosition = 0f;
 439
 44440        if (model.automaticTransition)
 44441            StartCarousel();
 442
 88443        foreach (Transform child in itemsContainer)
 444        {
 0445            ResizeItem((RectTransform)child);
 446        }
 44447    }
 448
 449    internal void DestroyInstantiatedItems()
 450    {
 593451        List<BaseComponentView> itemsToDestroy = ExtractItems();
 452
 1776453        foreach (BaseComponentView itemToDestroy in itemsToDestroy)
 454        {
 295455            if (itemToDestroy != null)
 295456                DestroyImmediate(itemToDestroy.gameObject);
 457        }
 458
 593459        itemsToDestroy.Clear();
 460
 593461        instantiatedItems.Clear();
 462
 593463        itemsContainer.offsetMin = Vector2.zero;
 593464        itemsContainer.offsetMax = Vector2.zero;
 593465    }
 466
 467    internal IEnumerator RunCarouselCoroutine(
 468        int fromIndex = 0,
 469        bool startInmediately = false,
 470        CarouselDirection direction = CarouselDirection.Right,
 471        bool changeDirectionAfterFirstTransition = false,
 472        int numberOfInitialJumps = 1)
 473    {
 137474        currentItemIndex = fromIndex;
 137475        SetSelectedDot(currentItemIndex);
 476
 137477        bool continueCarrousel = true;
 137478        while (gameObject.activeInHierarchy && itemsContainer.childCount > 1 && continueCarrousel)
 479        {
 10480            float elapsedTime = 0f;
 481
 10482            if (!startInmediately)
 483            {
 1484                while (elapsedTime < model.timeBetweenItems)
 485                {
 1486                    if (!model.pauseOnFocus || (model.pauseOnFocus && !isFocused))
 1487                        elapsedTime += Time.deltaTime;
 488
 1489                    yield return null;
 490                }
 491
 492            }
 493
 9494            if (instantiatedItems.Count > 0)
 495            {
 9496                if (direction == CarouselDirection.Right)
 497                {
 6498                    SetSelectedDot(currentItemIndex == (instantiatedItems.Count - 1) ? 0 : currentItemIndex + numberOfIn
 6499                    yield return RunRightAnimation(numberOfInitialJumps);
 500
 0501                    if (changeDirectionAfterFirstTransition)
 502                    {
 0503                        direction = CarouselDirection.Left;
 0504                        changeDirectionAfterFirstTransition = false;
 505                    }
 0506                    continueCarrousel = model.automaticTransition;
 0507                }
 508                else
 509                {
 3510                    SetSelectedDot(currentItemIndex == 0 ? (instantiatedItems.Count - 1) : currentItemIndex - numberOfIn
 3511                    yield return RunLeftAnimation(numberOfInitialJumps);
 512
 0513                    if (changeDirectionAfterFirstTransition)
 514                    {
 0515                        direction = CarouselDirection.Right;
 0516                        changeDirectionAfterFirstTransition = false;
 517                    }
 0518                    continueCarrousel = model.automaticTransition;
 519                }
 520            }
 521
 0522            startInmediately = false;
 0523            numberOfInitialJumps = 1;
 524        }
 127525    }
 526
 527    internal IEnumerator RunRightAnimation(int numberOfJumps = 1)
 528    {
 6529        if (currentItemIndex == instantiatedItems.Count - 1)
 530        {
 0531            currentItemIndex = 0;
 0532            yield return RunAnimationCoroutine(CarouselDirection.Left, instantiatedItems.Count - 1);
 0533        }
 534        else
 535        {
 6536            currentItemIndex += numberOfJumps;
 6537            yield return RunAnimationCoroutine(CarouselDirection.Right, numberOfJumps);
 538        }
 0539    }
 540
 541    internal IEnumerator RunLeftAnimation(int numberOfJumps = 1)
 542    {
 3543        if (currentItemIndex == 0)
 544        {
 3545            currentItemIndex = instantiatedItems.Count - 1;
 3546            yield return RunAnimationCoroutine(CarouselDirection.Right, instantiatedItems.Count - 1);
 0547        }
 548        else
 549        {
 0550            currentItemIndex -= numberOfJumps;
 0551            yield return RunAnimationCoroutine(CarouselDirection.Left, numberOfJumps);
 552        }
 0553    }
 554
 555    internal IEnumerator RunAnimationCoroutine(CarouselDirection direction, int numberOfJumps = 1)
 556    {
 9557        isInTransition = true;
 9558        float currentAnimationTime = 0f;
 9559        float initialNormalizedPos = itemsScroll.horizontalNormalizedPosition;
 560
 9561        if (direction == CarouselDirection.Right)
 9562            currentFinalNormalizedPos = initialNormalizedPos + ((float)numberOfJumps / (instantiatedItems.Count - 1));
 563        else
 0564            currentFinalNormalizedPos = initialNormalizedPos - ((float)numberOfJumps / (instantiatedItems.Count - 1));
 565
 9566        while (currentAnimationTime <= model.animationTransitionTime)
 567        {
 9568            itemsScroll.horizontalNormalizedPosition = Mathf.Clamp01(Mathf.Lerp(
 569                initialNormalizedPos,
 570                currentFinalNormalizedPos,
 571                model.animationCurve.Evaluate(currentAnimationTime / model.animationTransitionTime)));
 572
 9573            currentAnimationTime += Time.deltaTime;
 574
 9575            yield return null;
 576        }
 577
 0578        itemsScroll.horizontalNormalizedPosition = currentFinalNormalizedPos;
 0579        isInTransition = false;
 0580    }
 581
 582    public void GenerateDotsSelector()
 583    {
 38584        List<GameObject> dotsToRemove = new List<GameObject>();
 226585        foreach (Transform child in dotsSelector.transform)
 586        {
 75587            if (child.gameObject == dotButtonTemplate.gameObject)
 588                continue;
 589
 37590            dotsToRemove.Add(child.gameObject);
 591        }
 592
 150593        foreach (GameObject dotToRemove in dotsToRemove)
 594        {
 37595            Utils.SafeDestroy(dotToRemove);
 596        }
 597
 152598        for (int i = 0; i < itemsContainer.childCount; i++)
 599        {
 38600            Button newDotButton = Instantiate(dotButtonTemplate, dotsSelector.transform);
 38601            newDotButton.gameObject.SetActive(true);
 38602            newDotButton.onClick.AddListener(() =>
 603            {
 0604                int dotButtonIndex = newDotButton.transform.GetSiblingIndex() - 1;
 0605                if (dotButtonIndex != currentDotIndex)
 606                {
 0607                    MakeJumpFromDotsSelector(
 608                        Mathf.Abs(dotButtonIndex - currentDotIndex),
 609                        dotButtonIndex > currentDotIndex ? CarouselDirection.Right : CarouselDirection.Left);
 610                }
 0611            });
 612        }
 613
 38614        SetSelectedDot(0);
 38615    }
 616
 617    internal void SetSelectedDot(int index)
 618    {
 185619        int currentIndex = 0;
 185620        currentDotIndex = -1;
 1426621        foreach (Transform child in dotsSelector.transform)
 622        {
 528623            if (child.gameObject == dotButtonTemplate.gameObject)
 624                continue;
 625
 343626            if (currentIndex == index)
 627            {
 162628                child.GetComponent<Image>().color = dotSelectedColor;
 162629                child.transform.localScale = Vector3.one * 1.5f;
 162630                currentDotIndex = index;
 162631            }
 632            else
 633            {
 181634                child.GetComponent<Image>().color = dotUnselectedColor;
 181635                child.transform.localScale = Vector3.one;
 636            }
 637
 343638            currentIndex++;
 639        }
 185640    }
 641
 642    internal IEnumerator RegisterCurrentInstantiatedItems()
 643    {
 156644        instantiatedItems.Clear();
 645
 840646        foreach (Transform child in itemsContainer)
 647        {
 264648            BaseComponentView existingItem = child.GetComponent<BaseComponentView>();
 264649            if (existingItem != null)
 264650                instantiatedItems.Add(existingItem);
 651            else
 0652                Destroy(child.gameObject);
 653        }
 654
 655        // In the first loading, before calculating the size of the current items, it is needed to wait for a frame in o
 656        // allow time for the carousel viewport to get its final size to be able to execute the 'ResizeAllItems' functio
 156657        yield return null;
 658
 17659        ResizeAllItems();
 17660        SetManualControlsActive(model.showManualControls);
 17661        GenerateDotsSelector();
 17662    }
 663}