< 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:106
Coverable lines:320
Total lines:748
Line coverage:66.8% (214 of 320)
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%110100%
Initialize(...)0%440100%
Update()0%110100%
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%6200%
SelectHairColor(...)0%110100%
GetRandomColor()0%110100%
SelectSkinColor(...)0%110100%
SelectEyeColor(...)0%110100%
SetColors(...)0%110100%
UnselectAllWearables()0%330100%
UpdateAvatarPreview(...)0%4.054085.71%
AddFeedbackOnAppear()0%2100%
AddWearable(...)0%5.685070%
RefreshSelectorsSize()0%220100%
GetWearableCollectionName(...)0%4.123050%
RemoveWearable(...)0%30500%
RemoveAllWearables()0%220100%
OnRandomizeButton()0%12300%
OnDoneButton()0%2100%
OnWearablesSelectorsClicked(...)0%6200%
TakeSnapshotsAfterStopPreviewAnimation()0%12300%
OnSnapshotsReady(...)0%2100%
OnSnapshotsFailed()0%2100%
SetVisibility(...)0%7.037091.67%
Dispose()0%12120100%
SetAsFullScreenMenuMode(...)0%4.312016.67%
OnPointerDown(...)0%30500%
LoadCollectionsDropdown(...)0%6200%
BlockCollectionsDropdown(...)0%110100%
ShowSkinPopulatedList(...)0%110100%
ShowCollectiblesPopulatedList(...)0%110100%
SetThirdPartyCollectionsVisibility(...)0%110100%
ConfigureSectionSelector()0%110100%
SetSectionActive(...)0%220100%
PlayPreviewEmote(...)0%110100%
ResetPreviewEmote()0%110100%
ToggleThirdPartyCollection(...)0%12300%
ShowNoItemOfWearableCollectionWarning()0%2100%
ClickBlockerClicked()0%2100%
UpdateAvatarModelWhenNeeded()0%2.52050%

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;
 12using Random = System.Random;
 13
 14[assembly: InternalsVisibleTo("AvatarEditorHUDTests")]
 15
 16public class AvatarEditorHUDView : MonoBehaviour, IAvatarEditorHUDView, IPointerDownHandler
 17{
 118    private static readonly int RANDOMIZE_ANIMATOR_LOADING_BOOL = Animator.StringToHash("Loading");
 19    private const string VIEW_PATH = "AvatarEditorHUD";
 20    private const string VIEW_OBJECT_NAME = "_AvatarEditorHUD";
 21    internal const int AVATAR_SECTION_INDEX = 0;
 22    internal const string AVATAR_SECTION_TITLE = "Avatar";
 23    internal const int EMOTES_SECTION_INDEX = 1;
 24    internal const string EMOTES_SECTION_TITLE = "Emotes";
 25    private const string RESET_PREVIEW_ANIMATION = "Idle";
 26    private const float TIME_TO_RESET_PREVIEW_ANIMATION = 0.2f;
 27
 028    public bool isOpen { get; private set; }
 029    internal DataStore_EmotesCustomization emotesCustomizationDataStore => DataStore.i.emotesCustomization;
 30
 31    internal bool arePanelsInitialized = false;
 32
 33    [Serializable]
 34    public class AvatarEditorNavigationInfo
 35    {
 36        public Toggle toggle;
 37        public Canvas canvas;
 38        public bool enabledByDefault;
 39        public CharacterPreviewController.CameraFocus focus = CharacterPreviewController.CameraFocus.DefaultEditing;
 40
 41        //To remove when we refactor this to avoid ToggleGroup issues when quitting application
 188042        public void Initialize() { Application.quitting += () => toggle.onValueChanged.RemoveAllListeners(); }
 43    }
 44
 45    [Serializable]
 46    public class AvatarEditorWearableFilter
 47    {
 48        public string categoryFilter;
 49        public ItemSelector selector;
 50    }
 51
 52    [SerializeField]
 53    internal Canvas avatarEditorCanvas;
 54
 55    [SerializeField]
 56    internal CanvasGroup avatarEditorCanvasGroup;
 57
 58    [SerializeField]
 59    internal AvatarEditorNavigationInfo[] navigationInfos;
 60
 61    [SerializeField]
 62    internal AvatarEditorWearableFilter[] wearableGridPairs;
 63
 64    [SerializeField]
 65    internal AvatarEditorNavigationInfo collectiblesNavigationInfo;
 66
 67    [SerializeField]
 68    internal ItemSelector collectiblesItemSelector;
 69
 70    [SerializeField]
 71    internal ColorSelector skinColorSelector;
 72
 73    [SerializeField]
 74    internal ColorPickerComponentView eyeColorPickerComponent;
 75
 76    [SerializeField]
 77    internal ColorPickerComponentView hairColorPickerComponent;
 78
 79    [SerializeField]
 80    internal ColorPickerComponentView facialHairColorPickerComponent;
 81
 82    [SerializeField]
 83    internal ColorPickerComponentView eyeBrowsColorPickerComponent;
 84
 85    [SerializeField]
 86    internal PreviewCameraRotation characterPreviewRotation;
 87
 88    [SerializeField]
 89    internal Button randomizeButton;
 90
 91    [SerializeField]
 92    internal Animator randomizeAnimator;
 93
 94    [SerializeField]
 95    internal Button doneButton;
 96
 97    [SerializeField] internal Button[] goToMarketplaceButtons;
 98
 99    [SerializeField] internal GameObject loadingSpinnerGameObject;
 100
 101    [Header("Collectibles")]
 102    [SerializeField] internal GameObject web3Container;
 103    [SerializeField] internal GameObject noWeb3Container;
 104    [SerializeField] private GameObject collectiblesEmptyListContainer;
 105
 106    [Header("Skins")]
 107
 108    [SerializeField] internal GameObject skinsFeatureContainer;
 109
 110    [SerializeField] internal GameObject skinsWeb3Container;
 111
 112    [SerializeField] internal GameObject skinsMissingWeb3Container;
 113
 114    [SerializeField] internal GameObject skinsConnectWalletButtonContainer;
 115
 116    [SerializeField] private GameObject skinsPopulatedListContainer;
 117    [SerializeField] private GameObject skinsEmptyListContainer;
 118
 119    [SerializeField]
 120    internal DropdownComponentView collectionsDropdown;
 121
 122    [Header("Section Selector")]
 123    [SerializeField] internal SectionSelectorComponentView sectionSelector;
 124    [SerializeField] internal TMP_Text sectionTitle;
 125    [SerializeField] internal GameObject avatarSection;
 126    [SerializeField] internal GameObject emotesSection;
 127
 128    [SerializeField] internal UIHelper_ClickBlocker clickBlocker;
 129    [SerializeField] internal Notification noItemInCollectionWarning;
 130
 48131    public CharacterPreviewController characterPreviewController { get; private set; }
 132    private AvatarEditorHUDController controller;
 50133    internal readonly Dictionary<string, ItemSelector> selectorsByCategory = new Dictionary<string, ItemSelector>();
 50134    private readonly HashSet<WearableItem> wearablesWithLoadingSpinner = new HashSet<WearableItem>();
 50135    private readonly Dictionary<string, ToggleComponentModel> loadedCollectionModels = new Dictionary<string, ToggleComp
 136    private bool isAvatarDirty;
 137    private AvatarModel avatarModelToUpdate;
 138
 139    private bool doAvatarFeedback;
 140    public event Action<AvatarModel> OnAvatarAppearFeedback;
 141    public event Action<bool> OnSetVisibility;
 142    public event Action OnRandomize;
 143    public event Action<string> WearableSelectorClicked;
 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        isOpen = false;
 48150        arePanelsInitialized = false;
 48151    }
 152
 153    private void Initialize(AvatarEditorHUDController controller)
 154    {
 48155        this.controller = controller;
 48156        gameObject.name = VIEW_OBJECT_NAME;
 157
 48158        randomizeButton.onClick.AddListener(OnRandomizeButton);
 48159        doneButton.onClick.AddListener(OnDoneButton);
 48160        InitializeWearableChangeEvents();
 161
 576162        foreach (var button in goToMarketplaceButtons)
 240163            button.onClick.RemoveAllListeners();
 576164        foreach (var button in goToMarketplaceButtons)
 240165            button.onClick.AddListener(controller.GoToMarketplaceOrConnectWallet);
 166
 48167        characterPreviewController = Instantiate(Resources.Load<CharacterPreviewController>("CharacterPreview"));
 48168        characterPreviewController.name = "_CharacterPreviewController";
 48169        characterPreviewController.camera.enabled = false;
 170
 48171        collectionsDropdown.OnOptionSelectionChanged -= controller.ToggleThirdPartyCollection;
 48172        collectionsDropdown.OnOptionSelectionChanged += controller.ToggleThirdPartyCollection;
 173
 48174        clickBlocker.OnClicked += ClickBlockerClicked;
 175
 1728176        for (int i = 0; i < wearableGridPairs.Length; i++)
 177        {
 816178            wearableGridPairs[i].selector.OnItemClicked += OnWearablesSelectorsClicked;
 179        }
 48180        collectiblesItemSelector.OnItemClicked += OnWearablesSelectorsClicked;
 181
 48182        ConfigureSectionSelector();
 48183    }
 184
 185    private void Update()
 186    {
 1187        UpdateAvatarModelWhenNeeded();
 1188    }
 189
 190    public void SetIsWeb3(bool isWeb3User)
 191    {
 103192        web3Container.SetActive(isWeb3User);
 103193        noWeb3Container.SetActive(!isWeb3User);
 103194        skinsWeb3Container.SetActive(isWeb3User);
 103195        skinsMissingWeb3Container.SetActive(!isWeb3User);
 103196    }
 197
 198    internal void InitializeNavigationEvents(bool isGuest)
 199    {
 103200        if (arePanelsInitialized)
 56201            return;
 202
 1880203        for (int i = 0; i < navigationInfos.Length; i++)
 204        {
 893205            InitializeNavigationInfo(navigationInfos[i]);
 206        }
 47207        InitializeNavigationInfo(collectiblesNavigationInfo, !isGuest);
 208
 47209        characterPreviewRotation.OnHorizontalRotation += characterPreviewController.Rotate;
 47210        arePanelsInitialized = true;
 47211    }
 212
 213    private void InitializeNavigationInfo(AvatarEditorNavigationInfo current, bool isActive)
 214    {
 940215        current.Initialize();
 216
 940217        current.toggle.isOn = isActive ? current.enabledByDefault : false;
 940218        current.canvas.gameObject.SetActive(isActive ? current.enabledByDefault : false);
 219
 940220        current.toggle.onValueChanged.AddListener((on) =>
 221        {
 47222            current.canvas.gameObject.SetActive(@on);
 47223            characterPreviewController.SetFocus(current.focus);
 47224        });
 940225    }
 226
 227    private void InitializeNavigationInfo(AvatarEditorNavigationInfo current)
 228    {
 893229        InitializeNavigationInfo(current, true);
 893230    }
 231
 232    private void InitializeWearableChangeEvents()
 233    {
 48234        int nPairs = wearableGridPairs.Length;
 1728235        for (int i = 0; i < nPairs; i++)
 236        {
 816237            wearableGridPairs[i].selector.OnItemClicked += controller.WearableClicked;
 816238            wearableGridPairs[i].selector.OnSellClicked += controller.SellCollectible;
 816239            selectorsByCategory.Add(wearableGridPairs[i].categoryFilter, wearableGridPairs[i].selector);
 240        }
 241
 48242        collectiblesItemSelector.OnItemClicked += controller.WearableClicked;
 48243        collectiblesItemSelector.OnSellClicked += controller.SellCollectible;
 244
 48245        skinColorSelector.OnColorSelectorChange += controller.SkinColorClicked;
 48246        eyeColorPickerComponent.OnColorChanged += controller.EyesColorClicked;
 48247        hairColorPickerComponent.OnColorChanged += controller.HairColorClicked;
 48248        facialHairColorPickerComponent.OnColorChanged += controller.HairColorClicked;
 48249        eyeBrowsColorPickerComponent.OnColorChanged += controller.HairColorClicked;
 48250    }
 251
 252    internal static AvatarEditorHUDView Create(AvatarEditorHUDController controller)
 253    {
 48254        var view = Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<AvatarEditorHUDView>();
 48255        view.Initialize(controller);
 48256        return view;
 257    }
 258
 259    public void UpdateSelectedBody(WearableItem bodyShape)
 260    {
 2232261        for (int i = 0; i < wearableGridPairs.Length; i++)
 262        {
 1054263            if (wearableGridPairs[i].categoryFilter == WearableLiterals.Categories.BODY_SHAPE)
 264            {
 62265                wearableGridPairs[i].selector.UnselectAll();
 62266                wearableGridPairs[i].selector.Select(bodyShape.id);
 62267            }
 268            else
 269            {
 992270                wearableGridPairs[i].selector.SetBodyShape(bodyShape.id);
 271            }
 272        }
 273
 62274        collectiblesItemSelector.SetBodyShape(bodyShape.id);
 62275    }
 276
 277    public void EquipWearable(WearableItem wearable)
 278    {
 1090279        selectorsByCategory[wearable.data.category].Select(wearable.id);
 1090280        SetWearableLoadingSpinner(wearable, true);
 1090281        collectiblesItemSelector.Select(wearable.id);
 1090282    }
 283
 284    public void UnequipWearable(WearableItem wearable)
 285    {
 464286        selectorsByCategory[wearable.data.category].Unselect(wearable.id);
 464287        SetWearableLoadingSpinner(wearable, false);
 464288        collectiblesItemSelector.Unselect(wearable.id);
 464289    }
 290
 291    internal void SetWearableLoadingSpinner(WearableItem wearable, bool isActive)
 292    {
 1554293        selectorsByCategory[wearable.data.category].SetWearableLoadingSpinner(wearable.id, isActive);
 1554294        collectiblesItemSelector.SetWearableLoadingSpinner(wearable.id, isActive);
 1554295        if (isActive)
 1090296            wearablesWithLoadingSpinner.Add(wearable);
 297        else
 464298            wearablesWithLoadingSpinner.Remove(wearable);
 464299    }
 300
 301    internal void ClearWearablesLoadingSpinner()
 302    {
 0303        foreach (WearableItem wearable in wearablesWithLoadingSpinner)
 304        {
 0305            selectorsByCategory[wearable.data.category].SetWearableLoadingSpinner(wearable.id, false);
 0306            collectiblesItemSelector.SetWearableLoadingSpinner(wearable.id, false);
 307        }
 308
 0309        wearablesWithLoadingSpinner.Clear();
 0310    }
 311
 312    public void SelectHairColor(Color hairColor)
 313    {
 107314        hairColorPickerComponent.SetColorSelector(hairColor);
 107315        hairColorPickerComponent.UpdateSliderValues(hairColor);
 107316        eyeBrowsColorPickerComponent.SetColorSelector(hairColor);
 107317        eyeBrowsColorPickerComponent.UpdateSliderValues(hairColor);
 107318        facialHairColorPickerComponent.SetColorSelector(hairColor);
 107319        facialHairColorPickerComponent.UpdateSliderValues(hairColor);
 107320    }
 321
 322    public Color GetRandomColor()
 323    {
 2324        return Color.HSVToRGB(UnityEngine.Random.Range(0, 1f), UnityEngine.Random.Range(0, 1f), UnityEngine.Random.Range
 325    }
 326
 327    public void SelectSkinColor(Color skinColor)
 328    {
 106329        skinColorSelector.Select(skinColor);
 106330    }
 331
 332    public void SelectEyeColor(Color eyesColor)
 333    {
 107334        eyeColorPickerComponent.SetColorSelector(eyesColor);
 107335        eyeColorPickerComponent.UpdateSliderValues(eyesColor);
 107336    }
 337
 338    public void SetColors(List<Color> skinColors, List<Color> hairColors, List<Color> eyeColors)
 339    {
 48340        skinColorSelector.Populate(skinColors);
 48341        eyeColorPickerComponent.SetColorList(eyeColors);
 48342        hairColorPickerComponent.SetColorList(hairColors);
 48343        eyeBrowsColorPickerComponent.SetColorList(hairColors);
 48344        facialHairColorPickerComponent.SetColorList(hairColors);
 48345    }
 346
 347    public void UnselectAllWearables()
 348    {
 3708349        for (int i = 0; i < wearableGridPairs.Length; i++)
 350        {
 1751351            if (wearableGridPairs[i].categoryFilter != WearableLiterals.Categories.BODY_SHAPE)
 352            {
 1648353                wearableGridPairs[i].selector.UnselectAll();
 354            }
 355        }
 356
 103357        collectiblesItemSelector.UnselectAll();
 103358    }
 359
 360    public void UpdateAvatarPreview(AvatarModel avatarModel)
 361    {
 124362        if (avatarModel?.wearables == null)
 0363            return;
 364
 365        // We delay the updating of the avatar 1 frame to disengage from the kernel message flow
 366        // otherwise the cancellation of the updating task throws an exception that is catch by
 367        // kernel setthrew method, which floods the analytics.
 368        // Also it updates just once if its called many times in a row
 124369        isAvatarDirty = true;
 124370        avatarModelToUpdate = avatarModel;
 371
 124372        doneButton.interactable = false;
 124373        loadingSpinnerGameObject.SetActive(true);
 124374    }
 375
 376    public void AddFeedbackOnAppear()
 377    {
 0378        doAvatarFeedback = true;
 0379    }
 380
 381    public void AddWearable(WearableItem wearableItem, int amount,
 382        Func<WearableItem, bool> hideOtherWearablesToastStrategy,
 383        Func<WearableItem, bool> replaceOtherWearablesToastStrategy,
 384        Func<WearableItem, bool> incompatibleWearableToastStrategy)
 385    {
 4221386        if (wearableItem == null)
 0387            return;
 388
 4221389        if (!selectorsByCategory.ContainsKey(wearableItem.data.category))
 390        {
 0391            Debug.LogError($"Category couldn't find selector for category: {wearableItem.data.category} ");
 0392            return;
 393        }
 394
 4221395        string collectionName = GetWearableCollectionName(wearableItem);
 396
 4221397        selectorsByCategory[wearableItem.data.category].AddWearable(
 398            wearableItem,
 399            collectionName,
 400            amount,
 401            hideOtherWearablesToastStrategy,
 402            replaceOtherWearablesToastStrategy,
 403            incompatibleWearableToastStrategy);
 404
 4221405        if (wearableItem.IsCollectible() || wearableItem.IsFromThirdPartyCollection)
 406        {
 21407            collectiblesItemSelector.AddWearable(
 408                wearableItem,
 409                collectionName,
 410                amount,
 411                hideOtherWearablesToastStrategy,
 412                replaceOtherWearablesToastStrategy,
 413                incompatibleWearableToastStrategy);
 414        }
 4221415    }
 416
 417    public void RefreshSelectorsSize()
 418    {
 162419        using (var iterator = selectorsByCategory.GetEnumerator())
 420        {
 2916421            while (iterator.MoveNext())
 422            {
 2754423                iterator.Current.Value.UpdateSelectorLayout();
 424            }
 162425        }
 426
 162427        collectiblesItemSelector.UpdateSelectorLayout();
 162428    }
 429
 430    private string GetWearableCollectionName(WearableItem wearableItem)
 431    {
 4221432        string collectionName = string.Empty;
 433
 4221434        if (wearableItem.IsFromThirdPartyCollection)
 435        {
 0436            loadedCollectionModels.TryGetValue(wearableItem.ThirdPartyCollectionId, out ToggleComponentModel collectionM
 437
 0438            if (collectionModel != null)
 0439                collectionName = collectionModel.text;
 440        }
 441
 4221442        return collectionName;
 443    }
 444
 445    public void RemoveWearable(WearableItem wearableItem)
 446    {
 0447        if (wearableItem == null)
 0448            return;
 449
 0450        if (!selectorsByCategory.ContainsKey(wearableItem.data.category))
 451        {
 0452            Debug.LogError($"Category couldn't find selector for category: {wearableItem.data.category} ");
 0453            return;
 454        }
 455
 0456        selectorsByCategory[wearableItem.data.category].RemoveWearable(wearableItem.id);
 0457        if (wearableItem.IsCollectible() || wearableItem.IsFromThirdPartyCollection)
 0458            collectiblesItemSelector.RemoveWearable(wearableItem.id);
 0459    }
 460
 461    public void RemoveAllWearables()
 462    {
 151463        using (var enumerator = selectorsByCategory.GetEnumerator())
 464        {
 2718465            while (enumerator.MoveNext())
 466            {
 2567467                enumerator.Current.Value.RemoveAllWearables();
 468            }
 151469        }
 470
 151471        collectiblesItemSelector.RemoveAllWearables();
 151472    }
 473
 474    private void OnRandomizeButton()
 475    {
 0476        OnRandomize?.Invoke();
 0477        controller.RandomizeWearables();
 0478        randomizeAnimator?.SetBool(RANDOMIZE_ANIMATOR_LOADING_BOOL, true);
 0479    }
 480
 481    private void OnDoneButton()
 482    {
 0483        doneButton.interactable = false;
 0484        CoroutineStarter.Start(TakeSnapshotsAfterStopPreviewAnimation());
 0485        eyeColorPickerComponent.SetActive(false);
 0486        hairColorPickerComponent.SetActive(false);
 0487        facialHairColorPickerComponent.SetActive(false);
 0488        eyeBrowsColorPickerComponent.SetActive(false);
 0489    }
 490
 491    private void OnWearablesSelectorsClicked(string obj)
 492    {
 0493        WearableSelectorClicked?.Invoke(obj);
 0494    }
 495
 496    private IEnumerator TakeSnapshotsAfterStopPreviewAnimation()
 497    {
 498        // We need to stop the current preview animation in order to take a correct snapshot
 0499        ResetPreviewEmote();
 0500        yield return new WaitForSeconds(TIME_TO_RESET_PREVIEW_ANIMATION);
 0501        characterPreviewController.TakeSnapshots(OnSnapshotsReady, OnSnapshotsFailed);
 0502    }
 503
 504    private void OnSnapshotsReady(Texture2D face256, Texture2D body)
 505    {
 0506        doneButton.interactable = true;
 0507        controller.SaveAvatar(face256, body);
 0508    }
 509
 0510    private void OnSnapshotsFailed() { doneButton.interactable = true; }
 511
 512    public void SetVisibility(bool visible)
 513    {
 92514        characterPreviewController.camera.enabled = visible;
 92515        avatarEditorCanvas.enabled = visible;
 92516        avatarEditorCanvasGroup.blocksRaycasts = visible;
 517
 92518        if (visible && !isOpen)
 519        {
 43520            OnSetVisibility?.Invoke(visible);
 0521        }
 49522        else if (!visible && isOpen)
 523        {
 1524            collectionsDropdown.Close();
 1525            noItemInCollectionWarning.Dismiss(true);
 1526            OnSetVisibility?.Invoke(visible);
 527        }
 528
 92529        isOpen = visible;
 92530    }
 531
 532    public void Dispose()
 533    {
 48534        loadingSpinnerGameObject = null;
 48535        randomizeAnimator = null;
 48536        if (wearableGridPairs != null)
 537        {
 48538            int nPairs = wearableGridPairs.Length;
 1728539            for (int i = 0; i < nPairs; i++)
 540            {
 816541                var itemSelector = wearableGridPairs[i].selector;
 816542                if (itemSelector != null)
 543                {
 816544                    itemSelector.OnItemClicked -= controller.WearableClicked;
 816545                    itemSelector.OnSellClicked -= controller.SellCollectible;
 816546                    itemSelector.OnItemClicked -= OnWearablesSelectorsClicked;
 547                }
 548            }
 549        }
 550
 48551        if (collectiblesItemSelector != null)
 552        {
 48553            collectiblesItemSelector.OnItemClicked -= controller.WearableClicked;
 48554            collectiblesItemSelector.OnSellClicked -= controller.SellCollectible;
 48555            collectiblesItemSelector.OnItemClicked -= OnWearablesSelectorsClicked;
 556        }
 557
 48558        if (skinColorSelector != null)
 48559            skinColorSelector.OnColorSelectorChange -= controller.SkinColorClicked;
 48560        if (eyeColorPickerComponent != null)
 48561            eyeColorPickerComponent.OnColorChanged -= controller.EyesColorClicked;
 48562        if (hairColorPickerComponent != null)
 48563            hairColorPickerComponent.OnColorChanged -= controller.HairColorClicked;
 48564        if (facialHairColorPickerComponent != null)
 48565            facialHairColorPickerComponent.OnColorChanged -= controller.HairColorClicked;
 48566        if (eyeBrowsColorPickerComponent != null)
 48567            eyeBrowsColorPickerComponent.OnColorChanged -= controller.HairColorClicked;
 568
 48569        if (this != null)
 48570            Destroy(gameObject);
 571
 48572        if (characterPreviewController != null)
 573        {
 48574            Destroy(characterPreviewController.gameObject);
 48575            characterPreviewController = null;
 576        }
 577
 48578        collectionsDropdown.OnOptionSelectionChanged -= controller.ToggleThirdPartyCollection;
 48579        collectionsDropdown.Dispose();
 580
 48581        sectionSelector.GetSection(AVATAR_SECTION_INDEX).onSelect.RemoveAllListeners();
 48582        sectionSelector.GetSection(EMOTES_SECTION_INDEX).onSelect.RemoveAllListeners();
 583
 48584        clickBlocker.OnClicked -= ClickBlockerClicked;
 48585    }
 586
 587    public void SetAsFullScreenMenuMode(Transform parentTransform)
 588    {
 48589        if (parentTransform == null)
 48590            return;
 591
 0592        transform.SetParent(parentTransform);
 0593        transform.localScale = Vector3.one;
 594
 0595        RectTransform rectTransform = transform as RectTransform;
 0596        rectTransform.anchorMin = Vector2.zero;
 0597        rectTransform.anchorMax = Vector2.one;
 0598        rectTransform.pivot = new Vector2(0.5f, 0.5f);
 0599        rectTransform.localPosition = Vector2.zero;
 0600        rectTransform.offsetMax = Vector2.zero;
 0601        rectTransform.offsetMin = Vector2.zero;
 0602    }
 603
 604    public void OnPointerDown(PointerEventData eventData)
 605    {
 0606        if (eventData.pointerPressRaycast.gameObject != eyeColorPickerComponent.gameObject &&
 607            eventData.pointerPressRaycast.gameObject != hairColorPickerComponent.gameObject &&
 608            eventData.pointerPressRaycast.gameObject != eyeBrowsColorPickerComponent.gameObject &&
 609            eventData.pointerPressRaycast.gameObject != facialHairColorPickerComponent.gameObject)
 610        {
 0611            eyeColorPickerComponent.SetActive(false);
 0612            hairColorPickerComponent.SetActive(false);
 0613            eyeBrowsColorPickerComponent.SetActive(false);
 0614            facialHairColorPickerComponent.SetActive(false);
 615        }
 0616    }
 617
 618    public void LoadCollectionsDropdown(Collection[] collections)
 619    {
 0620        List<ToggleComponentModel> collectionsToAdd = new List<ToggleComponentModel>();
 0621        foreach (var collection in collections)
 622        {
 0623            ToggleComponentModel newCollectionModel = new ToggleComponentModel
 624            {
 625                id = collection.urn,
 626                text = collection.name,
 627                isOn = false,
 628                isTextActive = true
 629            };
 630
 0631            collectionsToAdd.Add(newCollectionModel);
 0632            loadedCollectionModels.Add(collection.urn, newCollectionModel);
 633        }
 634
 0635        collectionsDropdown.SetOptions(collectionsToAdd);
 0636    }
 637
 638    public void BlockCollectionsDropdown(bool isBlocked)
 639    {
 1640        collectionsDropdown.SetLoadingActive(isBlocked);
 1641    }
 642
 643    public void ShowSkinPopulatedList(bool show)
 644    {
 151645        skinsPopulatedListContainer.SetActive(show);
 151646        skinsEmptyListContainer.SetActive(!show);
 151647        skinsConnectWalletButtonContainer.SetActive(show);
 151648    }
 649
 650    public void ShowCollectiblesPopulatedList(bool show)
 651    {
 151652        collectiblesEmptyListContainer.SetActive(!show);
 151653    }
 654
 655    public void SetThirdPartyCollectionsVisibility(bool visible) =>
 48656        collectionsDropdown.gameObject.SetActive(visible);
 657
 658    internal void ConfigureSectionSelector()
 659    {
 48660        sectionTitle.text = AVATAR_SECTION_TITLE;
 661
 48662        sectionSelector.GetSection(AVATAR_SECTION_INDEX).onSelect.AddListener((isSelected) =>
 663        {
 0664            avatarSection.SetActive(isSelected);
 0665            randomizeButton.gameObject.SetActive(true);
 666
 0667            if (isSelected)
 668            {
 0669                sectionTitle.text = AVATAR_SECTION_TITLE;
 0670                ResetPreviewEmote();
 671            }
 672
 0673            emotesCustomizationDataStore.isEmotesCustomizationSelected.Set(false, notifyEvent: false);
 0674        });
 48675        sectionSelector.GetSection(EMOTES_SECTION_INDEX).onSelect.AddListener((isSelected) =>
 676        {
 0677            emotesSection.SetActive(isSelected);
 0678            randomizeButton.gameObject.SetActive(false);
 679
 0680            if (isSelected)
 681            {
 0682                sectionTitle.text = EMOTES_SECTION_TITLE;
 0683                ResetPreviewEmote();
 684            }
 685
 0686            characterPreviewController.SetFocus(CharacterPreviewController.CameraFocus.DefaultEditing);
 0687            emotesCustomizationDataStore.isEmotesCustomizationSelected.Set(true, notifyEvent: false);
 0688        });
 48689    }
 690
 691    internal void SetSectionActive(int sectionIndex, bool isActive)
 692    {
 96693        sectionSelector.GetSection(sectionIndex).SetActive(isActive);
 288694        sectionSelector.gameObject.SetActive(sectionSelector.GetAllSections().Count(x => x.IsActive()) > 1);
 96695    }
 696
 2697    public void PlayPreviewEmote(string emoteId) { characterPreviewController.PlayEmote(emoteId, (long)Time.realtimeSinc
 698
 2699    public void ResetPreviewEmote() { PlayPreviewEmote(RESET_PREVIEW_ANIMATION); }
 700
 701    public void ToggleThirdPartyCollection(string collectionId, bool isOn)
 702    {
 0703        List<IToggleComponentView> allCollectionOptions = collectionsDropdown.GetAllOptions();
 0704        foreach (IToggleComponentView collectionOption in allCollectionOptions)
 705        {
 0706            if (collectionOption.id == collectionId)
 0707                collectionOption.isOn = isOn;
 708        }
 0709    }
 710    public void ShowNoItemOfWearableCollectionWarning()
 711    {
 0712        noItemInCollectionWarning.Dismiss(true);
 0713        noItemInCollectionWarning.Show(new DCL.NotificationModel.Model
 714        {
 715            timer = 5f,
 716        });
 0717    }
 718
 719    private void ClickBlockerClicked()
 720    {
 0721        noItemInCollectionWarning.Dismiss(false);
 0722    }
 723
 724    private void UpdateAvatarModelWhenNeeded()
 725    {
 1726        if (isAvatarDirty)
 727        {
 0728            characterPreviewController.UpdateModel(avatarModelToUpdate,
 729                () =>
 730                {
 0731                    if (doneButton != null)
 0732                        doneButton.interactable = true;
 733
 0734                    loadingSpinnerGameObject?.SetActive(false);
 735
 0736                    if(doAvatarFeedback)
 0737                        OnAvatarAppearFeedback?.Invoke(avatarModelToUpdate);
 738
 0739                    doAvatarFeedback = false;
 0740                    ClearWearablesLoadingSpinner();
 0741                    randomizeAnimator?.SetBool(RANDOMIZE_ANIMATOR_LOADING_BOOL, false);
 0742                });
 743
 0744            isAvatarDirty = false;
 745        }
 1746    }
 747
 748}

Methods/Properties

AvatarEditorHUDView()
isOpen()
isOpen(System.Boolean)
emotesCustomizationDataStore()
Initialize()
characterPreviewController()
characterPreviewController(CharacterPreviewController)
AvatarEditorHUDView()
Awake()
Initialize(AvatarEditorHUDController)
Update()
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)
AddFeedbackOnAppear()
AddWearable(WearableItem, System.Int32, System.Func[WearableItem,Boolean], System.Func[WearableItem,Boolean], System.Func[WearableItem,Boolean])
RefreshSelectorsSize()
GetWearableCollectionName(WearableItem)
RemoveWearable(WearableItem)
RemoveAllWearables()
OnRandomizeButton()
OnDoneButton()
OnWearablesSelectorsClicked(System.String)
TakeSnapshotsAfterStopPreviewAnimation()
OnSnapshotsReady(UnityEngine.Texture2D, UnityEngine.Texture2D)
OnSnapshotsFailed()
SetVisibility(System.Boolean)
Dispose()
SetAsFullScreenMenuMode(UnityEngine.Transform)
OnPointerDown(UnityEngine.EventSystems.PointerEventData)
LoadCollectionsDropdown(WearableCollectionsAPIData/Collection[])
BlockCollectionsDropdown(System.Boolean)
ShowSkinPopulatedList(System.Boolean)
ShowCollectiblesPopulatedList(System.Boolean)
SetThirdPartyCollectionsVisibility(System.Boolean)
ConfigureSectionSelector()
SetSectionActive(System.Int32, System.Boolean)
PlayPreviewEmote(System.String)
ResetPreviewEmote()
ToggleThirdPartyCollection(System.String, System.Boolean)
ShowNoItemOfWearableCollectionWarning()
ClickBlockerClicked()
UpdateAvatarModelWhenNeeded()