< Summary

Class:AvatarEditorHUDView
Assembly:AvatarEditorHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/AvatarEditorHUD/Scripts/AvatarEditorHUDView.cs
Covered lines:214
Uncovered lines:91
Coverable lines:305
Total lines:710
Line coverage:70.1% (214 of 305)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
AvatarEditorHUDView()0%110100%
Initialize()0%110100%
AvatarEditorHUDView()0%110100%
Awake()0%220100%
Initialize(...)0%330100%
SetIsWeb3(...)0%110100%
InitializeNavigationEvents(...)0%330100%
InitializeNavigationInfo(...)0%550100%
InitializeNavigationInfo(...)0%110100%
InitializeWearableChangeEvents()0%220100%
Create(...)0%110100%
UpdateSelectedBody(...)0%330100%
EquipWearable(...)0%110100%
UnequipWearable(...)0%110100%
SetWearableLoadingSpinner(...)0%220100%
ClearWearablesLoadingSpinner()0%220100%
SelectHairColor(...)0%110100%
GetRandomColor()0%110100%
SelectSkinColor(...)0%110100%
SelectEyeColor(...)0%110100%
SetColors(...)0%110100%
UnselectAllWearables()0%330100%
UpdateAvatarPreview(...)0%4.074083.33%
AddWearable(...)0%5.685070%
RefreshSelectorsSize()0%220100%
GetWearableCollectionName(...)0%4.123050%
RemoveWearable(...)0%30500%
RemoveAllWearables()0%220100%
OnRandomizeButton()0%12300%
OnDoneButton()0%2100%
TakeSnapshotsAfterStopPreviewAnimation()0%12300%
OnSnapshotsReady(...)0%2100%
OnSnapshotsFailed()0%2100%
SetVisibility(...)0%7.037091.67%
CleanUp()0%12120100%
ShowCollectiblesLoadingSpinner(...)0%110100%
ShowCollectiblesLoadingRetry(...)0%110100%
SetAsFullScreenMenuMode(...)0%4.312016.67%
OnPointerDown(...)0%30500%
LoadCollectionsDropdown(...)0%6200%
BlockCollectionsDropdown(...)0%110100%
ShowSkinPopulatedList(...)0%2100%
SetThirdPartyCollectionsVisibility(...)0%110100%
ConfigureSectionSelector()0%110100%
SetSectionActive(...)0%220100%
PlayPreviewEmote(...)0%110100%
ResetPreviewEmote()0%110100%
ToggleThirdPartyCollection(...)0%12300%
ShowNoItemOfWearableCollectionWarning()0%2100%
ClickBlockerClicked()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/AvatarEditorHUD/Scripts/AvatarEditorHUDView.cs

#LineLine coverage
 1using DCL;
 2using System;
 3using System.Collections;
 4using System.Collections.Generic;
 5using System.Linq;
 6using System.Runtime.CompilerServices;
 7using TMPro;
 8using UnityEngine;
 9using UnityEngine.EventSystems;
 10using UnityEngine.UI;
 11using static WearableCollectionsAPIData;
 12
 13[assembly: InternalsVisibleTo("AvatarEditorHUDTests")]
 14
 15public class AvatarEditorHUDView : MonoBehaviour, IPointerDownHandler
 16{
 117    private static readonly int RANDOMIZE_ANIMATOR_LOADING_BOOL = Animator.StringToHash("Loading");
 18    private const string VIEW_PATH = "AvatarEditorHUD";
 19    private const string VIEW_OBJECT_NAME = "_AvatarEditorHUD";
 20    internal const int AVATAR_SECTION_INDEX = 0;
 21    internal const string AVATAR_SECTION_TITLE = "Avatar";
 22    internal const int EMOTES_SECTION_INDEX = 1;
 23    internal const string EMOTES_SECTION_TITLE = "Emotes";
 24    private const string RESET_PREVIEW_ANIMATION = "Idle";
 25    private const float TIME_TO_RESET_PREVIEW_ANIMATION = 0.2f;
 26
 027    public bool isOpen { get; private set; }
 028    internal DataStore_EmotesCustomization emotesCustomizationDataStore => DataStore.i.emotesCustomization;
 29
 30    internal bool arePanelsInitialized = false;
 31
 32    [Serializable]
 33    public class AvatarEditorNavigationInfo
 34    {
 35        public Toggle toggle;
 36        public Canvas canvas;
 37        public bool enabledByDefault;
 38        public CharacterPreviewController.CameraFocus focus = CharacterPreviewController.CameraFocus.DefaultEditing;
 39
 40        //To remove when we refactor this to avoid ToggleGroup issues when quitting application
 188041        public void Initialize() { Application.quitting += () => toggle.onValueChanged.RemoveAllListeners(); }
 42    }
 43
 44    [Serializable]
 45    public class AvatarEditorWearableFilter
 46    {
 47        public string categoryFilter;
 48        public ItemSelector selector;
 49    }
 50
 51    [SerializeField]
 52    internal Canvas avatarEditorCanvas;
 53
 54    [SerializeField]
 55    internal CanvasGroup avatarEditorCanvasGroup;
 56
 57    [SerializeField]
 58    internal AvatarEditorNavigationInfo[] navigationInfos;
 59
 60    [SerializeField]
 61    internal AvatarEditorWearableFilter[] wearableGridPairs;
 62
 63    [SerializeField]
 64    internal AvatarEditorNavigationInfo collectiblesNavigationInfo;
 65
 66    [SerializeField]
 67    internal ItemSelector collectiblesItemSelector;
 68
 69    [SerializeField]
 70    internal ColorSelector skinColorSelector;
 71
 72    [SerializeField]
 73    internal ColorPickerComponentView eyeColorPickerComponent;
 74
 75    [SerializeField]
 76    internal ColorPickerComponentView hairColorPickerComponent;
 77
 78    [SerializeField]
 79    internal ColorPickerComponentView facialHairColorPickerComponent;
 80
 81    [SerializeField]
 82    internal ColorPickerComponentView eyeBrowsColorPickerComponent;
 83
 84    [SerializeField]
 85    internal GameObject characterPreviewPrefab;
 86
 87    [SerializeField]
 88    internal PreviewCameraRotation characterPreviewRotation;
 89
 90    [SerializeField]
 91    internal Button randomizeButton;
 92
 93    [SerializeField]
 94    internal Animator randomizeAnimator;
 95
 96    [SerializeField]
 97    internal Button doneButton;
 98
 99    [SerializeField] internal Button[] goToMarketplaceButtons;
 100
 101    [SerializeField] internal GameObject loadingSpinnerGameObject;
 102
 103    [Header("Collectibles")]
 104    [SerializeField]
 105    internal GameObject web3Container;
 106
 107    [SerializeField]
 108    internal GameObject noWeb3Container;
 109
 110    [Header("Skins")]
 111
 112    [SerializeField] internal GameObject skinsFeatureContainer;
 113
 114    [SerializeField] internal GameObject skinsWeb3Container;
 115
 116    [SerializeField] internal GameObject skinsMissingWeb3Container;
 117
 118    [SerializeField] internal GameObject skinsConnectWalletButtonContainer;
 119
 120    [SerializeField] private GameObject skinsPopulatedListContainer;
 121    [SerializeField] private GameObject skinsEmptyListContainer;
 122
 123    [SerializeField]
 124    internal DropdownComponentView collectionsDropdown;
 125
 126    [Header("Section Selector")]
 127    [SerializeField] internal SectionSelectorComponentView sectionSelector;
 128    [SerializeField] internal TMP_Text sectionTitle;
 129    [SerializeField] internal GameObject avatarSection;
 130    [SerializeField] internal GameObject emotesSection;
 131
 132    [SerializeField] internal UIHelper_ClickBlocker clickBlocker;
 133    [SerializeField] internal Notification noItemInCollectionWarning;
 134
 135    internal static CharacterPreviewController characterPreviewController;
 136    private AvatarEditorHUDController controller;
 49137    internal readonly Dictionary<string, ItemSelector> selectorsByCategory = new Dictionary<string, ItemSelector>();
 49138    private readonly HashSet<WearableItem> wearablesWithLoadingSpinner = new HashSet<WearableItem>();
 49139    private Dictionary<string, ToggleComponentModel> loadedCollectionModels = new Dictionary<string, ToggleComponentMode
 140
 141    public event Action<AvatarModel> OnAvatarAppear;
 142    public event Action<bool> OnSetVisibility;
 143    public event Action OnRandomize;
 144
 145    private void Awake()
 146    {
 48147        loadingSpinnerGameObject.SetActive(false);
 48148        doneButton.interactable = false; //the default state of the button should be disable until a profile has been lo
 48149        if (characterPreviewController == null)
 150        {
 48151            characterPreviewController = Instantiate(characterPreviewPrefab).GetComponent<CharacterPreviewController>();
 48152            characterPreviewController.name = "_CharacterPreviewController";
 153        }
 154
 48155        isOpen = false;
 48156        arePanelsInitialized = false;
 48157    }
 158
 159    private void Initialize(AvatarEditorHUDController controller)
 160    {
 48161        this.controller = controller;
 48162        gameObject.name = VIEW_OBJECT_NAME;
 163
 48164        randomizeButton.onClick.AddListener(OnRandomizeButton);
 48165        doneButton.onClick.AddListener(OnDoneButton);
 48166        InitializeWearableChangeEvents();
 167
 576168        foreach (var button in goToMarketplaceButtons)
 240169            button.onClick.RemoveAllListeners();
 576170        foreach (var button in goToMarketplaceButtons)
 240171            button.onClick.AddListener(controller.GoToMarketplaceOrConnectWallet);
 172
 48173        characterPreviewController.camera.enabled = false;
 174
 48175        collectionsDropdown.OnOptionSelectionChanged -= controller.ToggleThirdPartyCollection;
 48176        collectionsDropdown.OnOptionSelectionChanged += controller.ToggleThirdPartyCollection;
 177
 48178        clickBlocker.OnClicked += ClickBlockerClicked;
 179
 48180        ConfigureSectionSelector();
 48181    }
 182
 183    public void SetIsWeb3(bool isWeb3User)
 184    {
 103185        web3Container.SetActive(isWeb3User);
 103186        noWeb3Container.SetActive(!isWeb3User);
 103187        skinsWeb3Container.SetActive(isWeb3User);
 103188        skinsMissingWeb3Container.SetActive(!isWeb3User);
 103189    }
 190
 191    internal void InitializeNavigationEvents(bool isGuest)
 192    {
 103193        if (arePanelsInitialized)
 56194            return;
 195
 1880196        for (int i = 0; i < navigationInfos.Length; i++)
 197        {
 893198            InitializeNavigationInfo(navigationInfos[i]);
 199        }
 47200        InitializeNavigationInfo(collectiblesNavigationInfo, !isGuest);
 201
 47202        characterPreviewRotation.OnHorizontalRotation += characterPreviewController.Rotate;
 47203        arePanelsInitialized = true;
 47204    }
 205
 206    private void InitializeNavigationInfo(AvatarEditorNavigationInfo current, bool isActive)
 207    {
 940208        current.Initialize();
 209
 940210        current.toggle.isOn = isActive ? current.enabledByDefault : false;
 940211        current.canvas.gameObject.SetActive(isActive ? current.enabledByDefault : false);
 212
 940213        current.toggle.onValueChanged.AddListener((on) =>
 214        {
 47215            current.canvas.gameObject.SetActive(@on);
 47216            characterPreviewController.SetFocus(current.focus);
 47217        });
 940218    }
 219
 220    private void InitializeNavigationInfo(AvatarEditorNavigationInfo current)
 221    {
 893222        InitializeNavigationInfo(current, true);
 893223    }
 224
 225    private void InitializeWearableChangeEvents()
 226    {
 48227        int nPairs = wearableGridPairs.Length;
 1728228        for (int i = 0; i < nPairs; i++)
 229        {
 816230            wearableGridPairs[i].selector.OnItemClicked += controller.WearableClicked;
 816231            wearableGridPairs[i].selector.OnSellClicked += controller.SellCollectible;
 816232            selectorsByCategory.Add(wearableGridPairs[i].categoryFilter, wearableGridPairs[i].selector);
 233        }
 234
 48235        collectiblesItemSelector.OnItemClicked += controller.WearableClicked;
 48236        collectiblesItemSelector.OnSellClicked += controller.SellCollectible;
 48237        collectiblesItemSelector.OnRetryClicked += controller.RetryLoadOwnedWearables;
 238
 48239        skinColorSelector.OnColorSelectorChange += controller.SkinColorClicked;
 48240        eyeColorPickerComponent.OnColorChanged += controller.EyesColorClicked;
 48241        hairColorPickerComponent.OnColorChanged += controller.HairColorClicked;
 48242        facialHairColorPickerComponent.OnColorChanged += controller.HairColorClicked;
 48243        eyeBrowsColorPickerComponent.OnColorChanged += controller.HairColorClicked;
 48244    }
 245
 246    internal static AvatarEditorHUDView Create(AvatarEditorHUDController controller)
 247    {
 48248        var view = Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<AvatarEditorHUDView>();
 48249        view.Initialize(controller);
 48250        return view;
 251    }
 252
 253    public void UpdateSelectedBody(WearableItem bodyShape)
 254    {
 1908255        for (int i = 0; i < wearableGridPairs.Length; i++)
 256        {
 901257            if (wearableGridPairs[i].categoryFilter == WearableLiterals.Categories.BODY_SHAPE)
 258            {
 53259                wearableGridPairs[i].selector.UnselectAll();
 53260                wearableGridPairs[i].selector.Select(bodyShape.id);
 53261            }
 262            else
 263            {
 848264                wearableGridPairs[i].selector.SetBodyShape(bodyShape.id);
 265            }
 266        }
 267
 53268        collectiblesItemSelector.SetBodyShape(bodyShape.id);
 53269    }
 270
 271    public void EquipWearable(WearableItem wearable)
 272    {
 1027273        selectorsByCategory[wearable.data.category].Select(wearable.id);
 1027274        SetWearableLoadingSpinner(wearable, true);
 1027275        collectiblesItemSelector.Select(wearable.id);
 1027276    }
 277
 278    public void UnequipWearable(WearableItem wearable)
 279    {
 464280        selectorsByCategory[wearable.data.category].Unselect(wearable.id);
 464281        SetWearableLoadingSpinner(wearable, false);
 464282        collectiblesItemSelector.Unselect(wearable.id);
 464283    }
 284
 285    internal void SetWearableLoadingSpinner(WearableItem wearable, bool isActive)
 286    {
 1491287        selectorsByCategory[wearable.data.category].SetWearableLoadingSpinner(wearable.id, isActive);
 1491288        collectiblesItemSelector.SetWearableLoadingSpinner(wearable.id, isActive);
 1491289        if (isActive)
 1027290            wearablesWithLoadingSpinner.Add(wearable);
 291        else
 464292            wearablesWithLoadingSpinner.Remove(wearable);
 464293    }
 294
 295    internal void ClearWearablesLoadingSpinner()
 296    {
 668297        foreach (WearableItem wearable in wearablesWithLoadingSpinner)
 298        {
 292299            selectorsByCategory[wearable.data.category].SetWearableLoadingSpinner(wearable.id, false);
 292300            collectiblesItemSelector.SetWearableLoadingSpinner(wearable.id, false);
 301        }
 302
 42303        wearablesWithLoadingSpinner.Clear();
 42304    }
 305
 306    public void SelectHairColor(Color hairColor)
 307    {
 108308        hairColorPickerComponent.SetColorSelector(hairColor);
 108309        hairColorPickerComponent.UpdateSliderValues(hairColor);
 108310        eyeBrowsColorPickerComponent.SetColorSelector(hairColor);
 108311        eyeBrowsColorPickerComponent.UpdateSliderValues(hairColor);
 108312        facialHairColorPickerComponent.SetColorSelector(hairColor);
 108313        facialHairColorPickerComponent.UpdateSliderValues(hairColor);
 108314    }
 315
 316    public Color GetRandomColor()
 317    {
 2318        return Color.HSVToRGB(UnityEngine.Random.Range(0, 1f), UnityEngine.Random.Range(0, 1f), UnityEngine.Random.Range
 319    }
 320
 321    public void SelectSkinColor(Color skinColor)
 322    {
 107323        skinColorSelector.Select(skinColor);
 107324    }
 325
 326    public void SelectEyeColor(Color eyesColor)
 327    {
 108328        eyeColorPickerComponent.SetColorSelector(eyesColor);
 108329        eyeColorPickerComponent.UpdateSliderValues(eyesColor);
 108330    }
 331
 332    public void SetColors(List<Color> skinColors, List<Color> hairColors, List<Color> eyeColors)
 333    {
 48334        skinColorSelector.Populate(skinColors);
 48335        eyeColorPickerComponent.SetColorList(eyeColors);
 48336        hairColorPickerComponent.SetColorList(hairColors);
 48337        eyeBrowsColorPickerComponent.SetColorList(hairColors);
 48338        facialHairColorPickerComponent.SetColorList(hairColors);
 48339    }
 340
 341    public void UnselectAllWearables()
 342    {
 3744343        for (int i = 0; i < wearableGridPairs.Length; i++)
 344        {
 1768345            if (wearableGridPairs[i].categoryFilter != WearableLiterals.Categories.BODY_SHAPE)
 346            {
 1664347                wearableGridPairs[i].selector.UnselectAll();
 348            }
 349        }
 350
 104351        collectiblesItemSelector.UnselectAll();
 104352    }
 353
 354    public void UpdateAvatarPreview(AvatarModel avatarModel, bool skipAudio)
 355    {
 125356        if (avatarModel?.wearables == null)
 0357            return;
 358
 125359        doneButton.interactable = false;
 125360        loadingSpinnerGameObject.SetActive(true);
 125361        characterPreviewController.UpdateModel(avatarModel,
 362            () =>
 363            {
 42364                if (doneButton != null)
 42365                    doneButton.interactable = true;
 366
 42367                loadingSpinnerGameObject?.SetActive(false);
 368
 42369                if(!skipAudio)
 0370                    OnAvatarAppear?.Invoke(avatarModel);
 371
 42372                ClearWearablesLoadingSpinner();
 42373                randomizeAnimator?.SetBool(RANDOMIZE_ANIMATOR_LOADING_BOOL, false);
 42374            });
 125375    }
 376
 377    public void AddWearable(WearableItem wearableItem, int amount,
 378        Func<WearableItem, bool> hideOtherWearablesToastStrategy,
 379        Func<WearableItem, bool> replaceOtherWearablesToastStrategy)
 380    {
 4221381        if (wearableItem == null)
 0382            return;
 383
 4221384        if (!selectorsByCategory.ContainsKey(wearableItem.data.category))
 385        {
 0386            Debug.LogError($"Category couldn't find selector for category: {wearableItem.data.category} ");
 0387            return;
 388        }
 389
 4221390        string collectionName = GetWearableCollectionName(wearableItem);
 391
 4221392        selectorsByCategory[wearableItem.data.category].AddItemToggle(
 393            wearableItem,
 394            collectionName,
 395            amount,
 396            hideOtherWearablesToastStrategy,
 397            replaceOtherWearablesToastStrategy);
 398
 4221399        if (wearableItem.IsCollectible() || wearableItem.IsFromThirdPartyCollection)
 400        {
 21401            collectiblesItemSelector.AddItemToggle(
 402                wearableItem,
 403                collectionName,
 404                amount,
 405                hideOtherWearablesToastStrategy,
 406                replaceOtherWearablesToastStrategy);
 407        }
 4221408    }
 409
 410    public void RefreshSelectorsSize()
 411    {
 151412        using (var iterator = selectorsByCategory.GetEnumerator())
 413        {
 2718414            while (iterator.MoveNext())
 415            {
 2567416                iterator.Current.Value.UpdateSelectorLayout();
 417            }
 151418        }
 419
 151420        collectiblesItemSelector.UpdateSelectorLayout();
 151421    }
 422
 423    private string GetWearableCollectionName(WearableItem wearableItem)
 424    {
 4221425        string collectionName = string.Empty;
 426
 4221427        if (wearableItem.IsFromThirdPartyCollection)
 428        {
 0429            loadedCollectionModels.TryGetValue(wearableItem.ThirdPartyCollectionId, out ToggleComponentModel collectionM
 430
 0431            if (collectionModel != null)
 0432                collectionName = collectionModel.text;
 433        }
 434
 4221435        return collectionName;
 436    }
 437
 438    public void RemoveWearable(WearableItem wearableItem)
 439    {
 0440        if (wearableItem == null)
 0441            return;
 442
 0443        if (!selectorsByCategory.ContainsKey(wearableItem.data.category))
 444        {
 0445            Debug.LogError($"Category couldn't find selector for category: {wearableItem.data.category} ");
 0446            return;
 447        }
 448
 0449        selectorsByCategory[wearableItem.data.category].RemoveItemToggle(wearableItem.id);
 0450        if (wearableItem.IsCollectible() || wearableItem.IsFromThirdPartyCollection)
 0451            collectiblesItemSelector.RemoveItemToggle(wearableItem.id);
 0452    }
 453
 454    public void RemoveAllWearables()
 455    {
 151456        using (var enumerator = selectorsByCategory.GetEnumerator())
 457        {
 2718458            while (enumerator.MoveNext())
 459            {
 2567460                enumerator.Current.Value.RemoveAllItemToggle();
 461            }
 151462        }
 463
 151464        collectiblesItemSelector.RemoveAllItemToggle();
 151465    }
 466
 467    private void OnRandomizeButton()
 468    {
 0469        OnRandomize?.Invoke();
 0470        controller.RandomizeWearables();
 0471        randomizeAnimator?.SetBool(RANDOMIZE_ANIMATOR_LOADING_BOOL, true);
 0472    }
 473
 474    private void OnDoneButton()
 475    {
 0476        doneButton.interactable = false;
 0477        CoroutineStarter.Start(TakeSnapshotsAfterStopPreviewAnimation());
 0478        eyeColorPickerComponent.SetActive(false);
 0479        hairColorPickerComponent.SetActive(false);
 0480        facialHairColorPickerComponent.SetActive(false);
 0481        eyeBrowsColorPickerComponent.SetActive(false);
 0482    }
 483
 484    private IEnumerator TakeSnapshotsAfterStopPreviewAnimation()
 485    {
 486        // We need to stop the current preview animation in order to take a correct snapshot
 0487        ResetPreviewEmote();
 0488        yield return new WaitForSeconds(TIME_TO_RESET_PREVIEW_ANIMATION);
 0489        characterPreviewController.TakeSnapshots(OnSnapshotsReady, OnSnapshotsFailed);
 0490    }
 491
 492    private void OnSnapshotsReady(Texture2D face256, Texture2D body)
 493    {
 0494        doneButton.interactable = true;
 0495        controller.SaveAvatar(face256, body);
 0496    }
 497
 0498    private void OnSnapshotsFailed() { doneButton.interactable = true; }
 499
 500    public void SetVisibility(bool visible)
 501    {
 92502        characterPreviewController.camera.enabled = visible;
 92503        avatarEditorCanvas.enabled = visible;
 92504        avatarEditorCanvasGroup.blocksRaycasts = visible;
 505
 92506        if (visible && !isOpen)
 507        {
 43508            OnSetVisibility?.Invoke(visible);
 0509        }
 49510        else if (!visible && isOpen)
 511        {
 1512            collectionsDropdown.Close();
 1513            noItemInCollectionWarning.Dismiss(true);
 1514            OnSetVisibility?.Invoke(visible);
 515        }
 516
 92517        isOpen = visible;
 92518    }
 519
 520    public void CleanUp()
 521    {
 48522        loadingSpinnerGameObject = null;
 48523        randomizeAnimator = null;
 48524        if (wearableGridPairs != null)
 525        {
 48526            int nPairs = wearableGridPairs.Length;
 1728527            for (int i = 0; i < nPairs; i++)
 528            {
 816529                var itemSelector = wearableGridPairs[i].selector;
 816530                if (itemSelector != null)
 531                {
 816532                    itemSelector.OnItemClicked -= controller.WearableClicked;
 816533                    itemSelector.OnSellClicked -= controller.SellCollectible;
 534                }
 535            }
 536        }
 537
 48538        if (collectiblesItemSelector != null)
 539        {
 48540            collectiblesItemSelector.OnItemClicked -= controller.WearableClicked;
 48541            collectiblesItemSelector.OnSellClicked -= controller.SellCollectible;
 48542            collectiblesItemSelector.OnRetryClicked -= controller.RetryLoadOwnedWearables;
 543        }
 544
 48545        if (skinColorSelector != null)
 48546            skinColorSelector.OnColorSelectorChange -= controller.SkinColorClicked;
 48547        if (eyeColorPickerComponent != null)
 48548            eyeColorPickerComponent.OnColorChanged -= controller.EyesColorClicked;
 48549        if (hairColorPickerComponent != null)
 48550            hairColorPickerComponent.OnColorChanged -= controller.HairColorClicked;
 48551        if (facialHairColorPickerComponent != null)
 48552            facialHairColorPickerComponent.OnColorChanged -= controller.HairColorClicked;
 48553        if (eyeBrowsColorPickerComponent != null)
 48554            eyeBrowsColorPickerComponent.OnColorChanged -= controller.HairColorClicked;
 555
 48556        if (this != null)
 48557            Destroy(gameObject);
 558
 48559        if (characterPreviewController != null)
 560        {
 48561            Destroy(characterPreviewController.gameObject);
 48562            characterPreviewController = null;
 563        }
 564
 48565        collectionsDropdown.OnOptionSelectionChanged -= controller.ToggleThirdPartyCollection;
 48566        collectionsDropdown.Dispose();
 567
 48568        sectionSelector.GetSection(AVATAR_SECTION_INDEX).onSelect.RemoveAllListeners();
 48569        sectionSelector.GetSection(EMOTES_SECTION_INDEX).onSelect.RemoveAllListeners();
 570
 48571        clickBlocker.OnClicked -= ClickBlockerClicked;
 48572    }
 573
 2574    public void ShowCollectiblesLoadingSpinner(bool isActive) { collectiblesItemSelector.ShowLoading(isActive); }
 575
 2576    public void ShowCollectiblesLoadingRetry(bool isActive) { collectiblesItemSelector.ShowRetryLoading(isActive); }
 577
 578    public void SetAsFullScreenMenuMode(Transform parentTransform)
 579    {
 48580        if (parentTransform == null)
 48581            return;
 582
 0583        transform.SetParent(parentTransform);
 0584        transform.localScale = Vector3.one;
 585
 0586        RectTransform rectTransform = transform as RectTransform;
 0587        rectTransform.anchorMin = Vector2.zero;
 0588        rectTransform.anchorMax = Vector2.one;
 0589        rectTransform.pivot = new Vector2(0.5f, 0.5f);
 0590        rectTransform.localPosition = Vector2.zero;
 0591        rectTransform.offsetMax = Vector2.zero;
 0592        rectTransform.offsetMin = Vector2.zero;
 0593    }
 594
 595    public void OnPointerDown(PointerEventData eventData)
 596    {
 0597        if (eventData.pointerPressRaycast.gameObject != eyeColorPickerComponent.gameObject &&
 598            eventData.pointerPressRaycast.gameObject != hairColorPickerComponent.gameObject &&
 599            eventData.pointerPressRaycast.gameObject != eyeBrowsColorPickerComponent.gameObject &&
 600            eventData.pointerPressRaycast.gameObject != facialHairColorPickerComponent.gameObject)
 601        {
 0602            eyeColorPickerComponent.SetActive(false);
 0603            hairColorPickerComponent.SetActive(false);
 0604            eyeBrowsColorPickerComponent.SetActive(false);
 0605            facialHairColorPickerComponent.SetActive(false);
 606        }
 0607    }
 608
 609    public void LoadCollectionsDropdown(Collection[] collections)
 610    {
 0611        List<ToggleComponentModel> collectionsToAdd = new List<ToggleComponentModel>();
 0612        foreach (var collection in collections)
 613        {
 0614            ToggleComponentModel newCollectionModel = new ToggleComponentModel
 615            {
 616                id = collection.urn,
 617                text = collection.name,
 618                isOn = false,
 619                isTextActive = true
 620            };
 621
 0622            collectionsToAdd.Add(newCollectionModel);
 0623            loadedCollectionModels.Add(collection.urn, newCollectionModel);
 624        }
 625
 0626        collectionsDropdown.SetOptions(collectionsToAdd);
 0627    }
 628
 629    public void BlockCollectionsDropdown(bool isBlocked)
 630    {
 1631        collectionsDropdown.SetLoadingActive(isBlocked);
 1632    }
 633
 634    public void ShowSkinPopulatedList(bool show)
 635    {
 0636        skinsPopulatedListContainer.SetActive(show);
 0637        skinsEmptyListContainer.SetActive(!show);
 0638        skinsConnectWalletButtonContainer.SetActive(show);
 0639    }
 640
 641    public void SetThirdPartyCollectionsVisibility(bool visible) =>
 48642        collectionsDropdown.gameObject.SetActive(visible);
 643
 644    internal void ConfigureSectionSelector()
 645    {
 48646        sectionTitle.text = AVATAR_SECTION_TITLE;
 647
 48648        sectionSelector.GetSection(AVATAR_SECTION_INDEX).onSelect.AddListener((isSelected) =>
 649        {
 0650            avatarSection.SetActive(isSelected);
 0651            randomizeButton.gameObject.SetActive(true);
 652
 0653            if (isSelected)
 654            {
 0655                sectionTitle.text = AVATAR_SECTION_TITLE;
 0656                ResetPreviewEmote();
 657            }
 658
 0659            emotesCustomizationDataStore.isEmotesCustomizationSelected.Set(false, notifyEvent: false);
 0660        });
 48661        sectionSelector.GetSection(EMOTES_SECTION_INDEX).onSelect.AddListener((isSelected) =>
 662        {
 0663            emotesSection.SetActive(isSelected);
 0664            randomizeButton.gameObject.SetActive(false);
 665
 0666            if (isSelected)
 667            {
 0668                sectionTitle.text = EMOTES_SECTION_TITLE;
 0669                ResetPreviewEmote();
 670            }
 671
 0672            characterPreviewController.SetFocus(CharacterPreviewController.CameraFocus.DefaultEditing);
 0673            emotesCustomizationDataStore.isEmotesCustomizationSelected.Set(true, notifyEvent: false);
 0674        });
 48675    }
 676
 677    internal void SetSectionActive(int sectionIndex, bool isActive)
 678    {
 96679        sectionSelector.GetSection(sectionIndex).SetActive(isActive);
 288680        sectionSelector.gameObject.SetActive(sectionSelector.GetAllSections().Count(x => x.IsActive()) > 1);
 96681    }
 682
 2683    public void PlayPreviewEmote(string emoteId) { characterPreviewController.PlayEmote(emoteId, (long)Time.realtimeSinc
 684
 2685    public void ResetPreviewEmote() { PlayPreviewEmote(RESET_PREVIEW_ANIMATION); }
 686
 687    public void ToggleThirdPartyCollection(string collectionId, bool isOn)
 688    {
 0689        List<IToggleComponentView> allCollectionOptions = collectionsDropdown.GetAllOptions();
 0690        foreach (IToggleComponentView collectionOption in allCollectionOptions)
 691        {
 0692            if (collectionOption.id == collectionId)
 0693                collectionOption.isOn = isOn;
 694        }
 0695    }
 696    public void ShowNoItemOfWearableCollectionWarning()
 697    {
 0698        noItemInCollectionWarning.Dismiss(true);
 0699        noItemInCollectionWarning.Show(new DCL.NotificationModel.Model
 700        {
 701            timer = 5f,
 702        });
 0703    }
 704
 705    private void ClickBlockerClicked()
 706    {
 0707        noItemInCollectionWarning.Dismiss(false);
 0708    }
 709
 710}

Methods/Properties

AvatarEditorHUDView()
isOpen()
isOpen(System.Boolean)
emotesCustomizationDataStore()
Initialize()
AvatarEditorHUDView()
Awake()
Initialize(AvatarEditorHUDController)
SetIsWeb3(System.Boolean)
InitializeNavigationEvents(System.Boolean)
InitializeNavigationInfo(AvatarEditorHUDView/AvatarEditorNavigationInfo, System.Boolean)
InitializeNavigationInfo(AvatarEditorHUDView/AvatarEditorNavigationInfo)
InitializeWearableChangeEvents()
Create(AvatarEditorHUDController)
UpdateSelectedBody(WearableItem)
EquipWearable(WearableItem)
UnequipWearable(WearableItem)
SetWearableLoadingSpinner(WearableItem, System.Boolean)
ClearWearablesLoadingSpinner()
SelectHairColor(UnityEngine.Color)
GetRandomColor()
SelectSkinColor(UnityEngine.Color)
SelectEyeColor(UnityEngine.Color)
SetColors(System.Collections.Generic.List[Color], System.Collections.Generic.List[Color], System.Collections.Generic.List[Color])
UnselectAllWearables()
UpdateAvatarPreview(AvatarModel, System.Boolean)
AddWearable(WearableItem, System.Int32, System.Func[WearableItem,Boolean], System.Func[WearableItem,Boolean])
RefreshSelectorsSize()
GetWearableCollectionName(WearableItem)
RemoveWearable(WearableItem)
RemoveAllWearables()
OnRandomizeButton()
OnDoneButton()
TakeSnapshotsAfterStopPreviewAnimation()
OnSnapshotsReady(UnityEngine.Texture2D, UnityEngine.Texture2D)
OnSnapshotsFailed()
SetVisibility(System.Boolean)
CleanUp()
ShowCollectiblesLoadingSpinner(System.Boolean)
ShowCollectiblesLoadingRetry(System.Boolean)
SetAsFullScreenMenuMode(UnityEngine.Transform)
OnPointerDown(UnityEngine.EventSystems.PointerEventData)
LoadCollectionsDropdown(WearableCollectionsAPIData/Collection[])
BlockCollectionsDropdown(System.Boolean)
ShowSkinPopulatedList(System.Boolean)
SetThirdPartyCollectionsVisibility(System.Boolean)
ConfigureSectionSelector()
SetSectionActive(System.Int32, System.Boolean)
PlayPreviewEmote(System.String)
ResetPreviewEmote()
ToggleThirdPartyCollection(System.String, System.Boolean)
ShowNoItemOfWearableCollectionWarning()
ClickBlockerClicked()