< 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:206
Uncovered lines:107
Coverable lines:313
Total lines:734
Line coverage:65.8% (206 of 313)
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%
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.034087.5%
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%2100%
ShowCollectiblesLoadingRetry(...)0%2100%
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%
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;
 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    private static CharacterPreviewController characterPreviewController;
 136    private AvatarEditorHUDController controller;
 50137    internal readonly Dictionary<string, ItemSelector> selectorsByCategory = new Dictionary<string, ItemSelector>();
 50138    private readonly HashSet<WearableItem> wearablesWithLoadingSpinner = new HashSet<WearableItem>();
 50139    private readonly Dictionary<string, ToggleComponentModel> loadedCollectionModels = new Dictionary<string, ToggleComp
 140    private bool isAvatarDirty;
 141    private AvatarModel avatarModelToUpdate;
 142    private bool updateAvatarShouldSkipAudio;
 143
 144    public event Action<AvatarModel> OnAvatarAppear;
 145    public event Action<bool> OnSetVisibility;
 146    public event Action OnRandomize;
 147
 148    private void Awake()
 149    {
 48150        loadingSpinnerGameObject.SetActive(false);
 48151        doneButton.interactable = false; //the default state of the button should be disable until a profile has been lo
 48152        if (characterPreviewController == null)
 153        {
 48154            characterPreviewController = Instantiate(characterPreviewPrefab).GetComponent<CharacterPreviewController>();
 48155            characterPreviewController.name = "_CharacterPreviewController";
 156        }
 157
 48158        isOpen = false;
 48159        arePanelsInitialized = false;
 48160    }
 161
 162    private void Initialize(AvatarEditorHUDController controller)
 163    {
 48164        this.controller = controller;
 48165        gameObject.name = VIEW_OBJECT_NAME;
 166
 48167        randomizeButton.onClick.AddListener(OnRandomizeButton);
 48168        doneButton.onClick.AddListener(OnDoneButton);
 48169        InitializeWearableChangeEvents();
 170
 576171        foreach (var button in goToMarketplaceButtons)
 240172            button.onClick.RemoveAllListeners();
 576173        foreach (var button in goToMarketplaceButtons)
 240174            button.onClick.AddListener(controller.GoToMarketplaceOrConnectWallet);
 175
 48176        characterPreviewController.camera.enabled = false;
 177
 48178        collectionsDropdown.OnOptionSelectionChanged -= controller.ToggleThirdPartyCollection;
 48179        collectionsDropdown.OnOptionSelectionChanged += controller.ToggleThirdPartyCollection;
 180
 48181        clickBlocker.OnClicked += ClickBlockerClicked;
 182
 48183        ConfigureSectionSelector();
 48184    }
 185
 186    private void Update()
 187    {
 1188        UpdateAvatarModelWhenNeeded();
 1189    }
 190
 191    public void SetIsWeb3(bool isWeb3User)
 192    {
 103193        web3Container.SetActive(isWeb3User);
 103194        noWeb3Container.SetActive(!isWeb3User);
 103195        skinsWeb3Container.SetActive(isWeb3User);
 103196        skinsMissingWeb3Container.SetActive(!isWeb3User);
 103197    }
 198
 199    internal void InitializeNavigationEvents(bool isGuest)
 200    {
 103201        if (arePanelsInitialized)
 56202            return;
 203
 1880204        for (int i = 0; i < navigationInfos.Length; i++)
 205        {
 893206            InitializeNavigationInfo(navigationInfos[i]);
 207        }
 47208        InitializeNavigationInfo(collectiblesNavigationInfo, !isGuest);
 209
 47210        characterPreviewRotation.OnHorizontalRotation += characterPreviewController.Rotate;
 47211        arePanelsInitialized = true;
 47212    }
 213
 214    private void InitializeNavigationInfo(AvatarEditorNavigationInfo current, bool isActive)
 215    {
 940216        current.Initialize();
 217
 940218        current.toggle.isOn = isActive ? current.enabledByDefault : false;
 940219        current.canvas.gameObject.SetActive(isActive ? current.enabledByDefault : false);
 220
 940221        current.toggle.onValueChanged.AddListener((on) =>
 222        {
 47223            current.canvas.gameObject.SetActive(@on);
 47224            characterPreviewController.SetFocus(current.focus);
 47225        });
 940226    }
 227
 228    private void InitializeNavigationInfo(AvatarEditorNavigationInfo current)
 229    {
 893230        InitializeNavigationInfo(current, true);
 893231    }
 232
 233    private void InitializeWearableChangeEvents()
 234    {
 48235        int nPairs = wearableGridPairs.Length;
 1728236        for (int i = 0; i < nPairs; i++)
 237        {
 816238            wearableGridPairs[i].selector.OnItemClicked += controller.WearableClicked;
 816239            wearableGridPairs[i].selector.OnSellClicked += controller.SellCollectible;
 816240            selectorsByCategory.Add(wearableGridPairs[i].categoryFilter, wearableGridPairs[i].selector);
 241        }
 242
 48243        collectiblesItemSelector.OnItemClicked += controller.WearableClicked;
 48244        collectiblesItemSelector.OnSellClicked += controller.SellCollectible;
 48245        collectiblesItemSelector.OnRetryClicked += controller.RetryLoadOwnedWearables;
 246
 48247        skinColorSelector.OnColorSelectorChange += controller.SkinColorClicked;
 48248        eyeColorPickerComponent.OnColorChanged += controller.EyesColorClicked;
 48249        hairColorPickerComponent.OnColorChanged += controller.HairColorClicked;
 48250        facialHairColorPickerComponent.OnColorChanged += controller.HairColorClicked;
 48251        eyeBrowsColorPickerComponent.OnColorChanged += controller.HairColorClicked;
 48252    }
 253
 254    internal static AvatarEditorHUDView Create(AvatarEditorHUDController controller)
 255    {
 48256        var view = Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<AvatarEditorHUDView>();
 48257        view.Initialize(controller);
 48258        return view;
 259    }
 260
 261    public void UpdateSelectedBody(WearableItem bodyShape)
 262    {
 1908263        for (int i = 0; i < wearableGridPairs.Length; i++)
 264        {
 901265            if (wearableGridPairs[i].categoryFilter == WearableLiterals.Categories.BODY_SHAPE)
 266            {
 53267                wearableGridPairs[i].selector.UnselectAll();
 53268                wearableGridPairs[i].selector.Select(bodyShape.id);
 53269            }
 270            else
 271            {
 848272                wearableGridPairs[i].selector.SetBodyShape(bodyShape.id);
 273            }
 274        }
 275
 53276        collectiblesItemSelector.SetBodyShape(bodyShape.id);
 53277    }
 278
 279    public void EquipWearable(WearableItem wearable)
 280    {
 1027281        selectorsByCategory[wearable.data.category].Select(wearable.id);
 1027282        SetWearableLoadingSpinner(wearable, true);
 1027283        collectiblesItemSelector.Select(wearable.id);
 1027284    }
 285
 286    public void UnequipWearable(WearableItem wearable)
 287    {
 464288        selectorsByCategory[wearable.data.category].Unselect(wearable.id);
 464289        SetWearableLoadingSpinner(wearable, false);
 464290        collectiblesItemSelector.Unselect(wearable.id);
 464291    }
 292
 293    internal void SetWearableLoadingSpinner(WearableItem wearable, bool isActive)
 294    {
 1491295        selectorsByCategory[wearable.data.category].SetWearableLoadingSpinner(wearable.id, isActive);
 1491296        collectiblesItemSelector.SetWearableLoadingSpinner(wearable.id, isActive);
 1491297        if (isActive)
 1027298            wearablesWithLoadingSpinner.Add(wearable);
 299        else
 464300            wearablesWithLoadingSpinner.Remove(wearable);
 464301    }
 302
 303    internal void ClearWearablesLoadingSpinner()
 304    {
 0305        foreach (WearableItem wearable in wearablesWithLoadingSpinner)
 306        {
 0307            selectorsByCategory[wearable.data.category].SetWearableLoadingSpinner(wearable.id, false);
 0308            collectiblesItemSelector.SetWearableLoadingSpinner(wearable.id, false);
 309        }
 310
 0311        wearablesWithLoadingSpinner.Clear();
 0312    }
 313
 314    public void SelectHairColor(Color hairColor)
 315    {
 108316        hairColorPickerComponent.SetColorSelector(hairColor);
 108317        hairColorPickerComponent.UpdateSliderValues(hairColor);
 108318        eyeBrowsColorPickerComponent.SetColorSelector(hairColor);
 108319        eyeBrowsColorPickerComponent.UpdateSliderValues(hairColor);
 108320        facialHairColorPickerComponent.SetColorSelector(hairColor);
 108321        facialHairColorPickerComponent.UpdateSliderValues(hairColor);
 108322    }
 323
 324    public Color GetRandomColor()
 325    {
 2326        return Color.HSVToRGB(UnityEngine.Random.Range(0, 1f), UnityEngine.Random.Range(0, 1f), UnityEngine.Random.Range
 327    }
 328
 329    public void SelectSkinColor(Color skinColor)
 330    {
 107331        skinColorSelector.Select(skinColor);
 107332    }
 333
 334    public void SelectEyeColor(Color eyesColor)
 335    {
 108336        eyeColorPickerComponent.SetColorSelector(eyesColor);
 108337        eyeColorPickerComponent.UpdateSliderValues(eyesColor);
 108338    }
 339
 340    public void SetColors(List<Color> skinColors, List<Color> hairColors, List<Color> eyeColors)
 341    {
 48342        skinColorSelector.Populate(skinColors);
 48343        eyeColorPickerComponent.SetColorList(eyeColors);
 48344        hairColorPickerComponent.SetColorList(hairColors);
 48345        eyeBrowsColorPickerComponent.SetColorList(hairColors);
 48346        facialHairColorPickerComponent.SetColorList(hairColors);
 48347    }
 348
 349    public void UnselectAllWearables()
 350    {
 3744351        for (int i = 0; i < wearableGridPairs.Length; i++)
 352        {
 1768353            if (wearableGridPairs[i].categoryFilter != WearableLiterals.Categories.BODY_SHAPE)
 354            {
 1664355                wearableGridPairs[i].selector.UnselectAll();
 356            }
 357        }
 358
 104359        collectiblesItemSelector.UnselectAll();
 104360    }
 361
 362    public void UpdateAvatarPreview(AvatarModel avatarModel, bool skipAudio)
 363    {
 125364        if (avatarModel?.wearables == null)
 0365            return;
 366
 367        // We delay the updating of the avatar 1 frame to disengage from the kernel message flow
 368        // otherwise the cancellation of the updating task throws an exception that is catch by
 369        // kernel setthrew method, which floods the analytics.
 370        // Also it updates just once if its called many times in a row
 125371        isAvatarDirty = true;
 125372        avatarModelToUpdate = avatarModel;
 125373        updateAvatarShouldSkipAudio = skipAudio;
 374
 125375        doneButton.interactable = false;
 125376        loadingSpinnerGameObject.SetActive(true);
 125377    }
 378
 379    public void AddWearable(WearableItem wearableItem, int amount,
 380        Func<WearableItem, bool> hideOtherWearablesToastStrategy,
 381        Func<WearableItem, bool> replaceOtherWearablesToastStrategy)
 382    {
 4221383        if (wearableItem == null)
 0384            return;
 385
 4221386        if (!selectorsByCategory.ContainsKey(wearableItem.data.category))
 387        {
 0388            Debug.LogError($"Category couldn't find selector for category: {wearableItem.data.category} ");
 0389            return;
 390        }
 391
 4221392        string collectionName = GetWearableCollectionName(wearableItem);
 393
 4221394        selectorsByCategory[wearableItem.data.category].AddItemToggle(
 395            wearableItem,
 396            collectionName,
 397            amount,
 398            hideOtherWearablesToastStrategy,
 399            replaceOtherWearablesToastStrategy);
 400
 4221401        if (wearableItem.IsCollectible() || wearableItem.IsFromThirdPartyCollection)
 402        {
 21403            collectiblesItemSelector.AddItemToggle(
 404                wearableItem,
 405                collectionName,
 406                amount,
 407                hideOtherWearablesToastStrategy,
 408                replaceOtherWearablesToastStrategy);
 409        }
 4221410    }
 411
 412    public void RefreshSelectorsSize()
 413    {
 151414        using (var iterator = selectorsByCategory.GetEnumerator())
 415        {
 2718416            while (iterator.MoveNext())
 417            {
 2567418                iterator.Current.Value.UpdateSelectorLayout();
 419            }
 151420        }
 421
 151422        collectiblesItemSelector.UpdateSelectorLayout();
 151423    }
 424
 425    private string GetWearableCollectionName(WearableItem wearableItem)
 426    {
 4221427        string collectionName = string.Empty;
 428
 4221429        if (wearableItem.IsFromThirdPartyCollection)
 430        {
 0431            loadedCollectionModels.TryGetValue(wearableItem.ThirdPartyCollectionId, out ToggleComponentModel collectionM
 432
 0433            if (collectionModel != null)
 0434                collectionName = collectionModel.text;
 435        }
 436
 4221437        return collectionName;
 438    }
 439
 440    public void RemoveWearable(WearableItem wearableItem)
 441    {
 0442        if (wearableItem == null)
 0443            return;
 444
 0445        if (!selectorsByCategory.ContainsKey(wearableItem.data.category))
 446        {
 0447            Debug.LogError($"Category couldn't find selector for category: {wearableItem.data.category} ");
 0448            return;
 449        }
 450
 0451        selectorsByCategory[wearableItem.data.category].RemoveItemToggle(wearableItem.id);
 0452        if (wearableItem.IsCollectible() || wearableItem.IsFromThirdPartyCollection)
 0453            collectiblesItemSelector.RemoveItemToggle(wearableItem.id);
 0454    }
 455
 456    public void RemoveAllWearables()
 457    {
 151458        using (var enumerator = selectorsByCategory.GetEnumerator())
 459        {
 2718460            while (enumerator.MoveNext())
 461            {
 2567462                enumerator.Current.Value.RemoveAllItemToggle();
 463            }
 151464        }
 465
 151466        collectiblesItemSelector.RemoveAllItemToggle();
 151467    }
 468
 469    private void OnRandomizeButton()
 470    {
 0471        OnRandomize?.Invoke();
 0472        controller.RandomizeWearables();
 0473        randomizeAnimator?.SetBool(RANDOMIZE_ANIMATOR_LOADING_BOOL, true);
 0474    }
 475
 476    private void OnDoneButton()
 477    {
 0478        doneButton.interactable = false;
 0479        CoroutineStarter.Start(TakeSnapshotsAfterStopPreviewAnimation());
 0480        eyeColorPickerComponent.SetActive(false);
 0481        hairColorPickerComponent.SetActive(false);
 0482        facialHairColorPickerComponent.SetActive(false);
 0483        eyeBrowsColorPickerComponent.SetActive(false);
 0484    }
 485
 486    private IEnumerator TakeSnapshotsAfterStopPreviewAnimation()
 487    {
 488        // We need to stop the current preview animation in order to take a correct snapshot
 0489        ResetPreviewEmote();
 0490        yield return new WaitForSeconds(TIME_TO_RESET_PREVIEW_ANIMATION);
 0491        characterPreviewController.TakeSnapshots(OnSnapshotsReady, OnSnapshotsFailed);
 0492    }
 493
 494    private void OnSnapshotsReady(Texture2D face256, Texture2D body)
 495    {
 0496        doneButton.interactable = true;
 0497        controller.SaveAvatar(face256, body);
 0498    }
 499
 0500    private void OnSnapshotsFailed() { doneButton.interactable = true; }
 501
 502    public void SetVisibility(bool visible)
 503    {
 92504        characterPreviewController.camera.enabled = visible;
 92505        avatarEditorCanvas.enabled = visible;
 92506        avatarEditorCanvasGroup.blocksRaycasts = visible;
 507
 92508        if (visible && !isOpen)
 509        {
 43510            OnSetVisibility?.Invoke(visible);
 0511        }
 49512        else if (!visible && isOpen)
 513        {
 1514            collectionsDropdown.Close();
 1515            noItemInCollectionWarning.Dismiss(true);
 1516            OnSetVisibility?.Invoke(visible);
 517        }
 518
 92519        isOpen = visible;
 92520    }
 521
 522    public void CleanUp()
 523    {
 48524        loadingSpinnerGameObject = null;
 48525        randomizeAnimator = null;
 48526        if (wearableGridPairs != null)
 527        {
 48528            int nPairs = wearableGridPairs.Length;
 1728529            for (int i = 0; i < nPairs; i++)
 530            {
 816531                var itemSelector = wearableGridPairs[i].selector;
 816532                if (itemSelector != null)
 533                {
 816534                    itemSelector.OnItemClicked -= controller.WearableClicked;
 816535                    itemSelector.OnSellClicked -= controller.SellCollectible;
 536                }
 537            }
 538        }
 539
 48540        if (collectiblesItemSelector != null)
 541        {
 48542            collectiblesItemSelector.OnItemClicked -= controller.WearableClicked;
 48543            collectiblesItemSelector.OnSellClicked -= controller.SellCollectible;
 48544            collectiblesItemSelector.OnRetryClicked -= controller.RetryLoadOwnedWearables;
 545        }
 546
 48547        if (skinColorSelector != null)
 48548            skinColorSelector.OnColorSelectorChange -= controller.SkinColorClicked;
 48549        if (eyeColorPickerComponent != null)
 48550            eyeColorPickerComponent.OnColorChanged -= controller.EyesColorClicked;
 48551        if (hairColorPickerComponent != null)
 48552            hairColorPickerComponent.OnColorChanged -= controller.HairColorClicked;
 48553        if (facialHairColorPickerComponent != null)
 48554            facialHairColorPickerComponent.OnColorChanged -= controller.HairColorClicked;
 48555        if (eyeBrowsColorPickerComponent != null)
 48556            eyeBrowsColorPickerComponent.OnColorChanged -= controller.HairColorClicked;
 557
 48558        if (this != null)
 48559            Destroy(gameObject);
 560
 48561        if (characterPreviewController != null)
 562        {
 48563            Destroy(characterPreviewController.gameObject);
 48564            characterPreviewController = null;
 565        }
 566
 48567        collectionsDropdown.OnOptionSelectionChanged -= controller.ToggleThirdPartyCollection;
 48568        collectionsDropdown.Dispose();
 569
 48570        sectionSelector.GetSection(AVATAR_SECTION_INDEX).onSelect.RemoveAllListeners();
 48571        sectionSelector.GetSection(EMOTES_SECTION_INDEX).onSelect.RemoveAllListeners();
 572
 48573        clickBlocker.OnClicked -= ClickBlockerClicked;
 48574    }
 575
 0576    public void ShowCollectiblesLoadingSpinner(bool isActive) { collectiblesItemSelector.ShowLoading(isActive); }
 577
 0578    public void ShowCollectiblesLoadingRetry(bool isActive) { collectiblesItemSelector.ShowRetryLoading(isActive); }
 579
 580    public void SetAsFullScreenMenuMode(Transform parentTransform)
 581    {
 48582        if (parentTransform == null)
 48583            return;
 584
 0585        transform.SetParent(parentTransform);
 0586        transform.localScale = Vector3.one;
 587
 0588        RectTransform rectTransform = transform as RectTransform;
 0589        rectTransform.anchorMin = Vector2.zero;
 0590        rectTransform.anchorMax = Vector2.one;
 0591        rectTransform.pivot = new Vector2(0.5f, 0.5f);
 0592        rectTransform.localPosition = Vector2.zero;
 0593        rectTransform.offsetMax = Vector2.zero;
 0594        rectTransform.offsetMin = Vector2.zero;
 0595    }
 596
 597    public void OnPointerDown(PointerEventData eventData)
 598    {
 0599        if (eventData.pointerPressRaycast.gameObject != eyeColorPickerComponent.gameObject &&
 600            eventData.pointerPressRaycast.gameObject != hairColorPickerComponent.gameObject &&
 601            eventData.pointerPressRaycast.gameObject != eyeBrowsColorPickerComponent.gameObject &&
 602            eventData.pointerPressRaycast.gameObject != facialHairColorPickerComponent.gameObject)
 603        {
 0604            eyeColorPickerComponent.SetActive(false);
 0605            hairColorPickerComponent.SetActive(false);
 0606            eyeBrowsColorPickerComponent.SetActive(false);
 0607            facialHairColorPickerComponent.SetActive(false);
 608        }
 0609    }
 610
 611    public void LoadCollectionsDropdown(Collection[] collections)
 612    {
 0613        List<ToggleComponentModel> collectionsToAdd = new List<ToggleComponentModel>();
 0614        foreach (var collection in collections)
 615        {
 0616            ToggleComponentModel newCollectionModel = new ToggleComponentModel
 617            {
 618                id = collection.urn,
 619                text = collection.name,
 620                isOn = false,
 621                isTextActive = true
 622            };
 623
 0624            collectionsToAdd.Add(newCollectionModel);
 0625            loadedCollectionModels.Add(collection.urn, newCollectionModel);
 626        }
 627
 0628        collectionsDropdown.SetOptions(collectionsToAdd);
 0629    }
 630
 631    public void BlockCollectionsDropdown(bool isBlocked)
 632    {
 1633        collectionsDropdown.SetLoadingActive(isBlocked);
 1634    }
 635
 636    public void ShowSkinPopulatedList(bool show)
 637    {
 0638        skinsPopulatedListContainer.SetActive(show);
 0639        skinsEmptyListContainer.SetActive(!show);
 0640        skinsConnectWalletButtonContainer.SetActive(show);
 0641    }
 642
 643    public void SetThirdPartyCollectionsVisibility(bool visible) =>
 48644        collectionsDropdown.gameObject.SetActive(visible);
 645
 646    internal void ConfigureSectionSelector()
 647    {
 48648        sectionTitle.text = AVATAR_SECTION_TITLE;
 649
 48650        sectionSelector.GetSection(AVATAR_SECTION_INDEX).onSelect.AddListener((isSelected) =>
 651        {
 0652            avatarSection.SetActive(isSelected);
 0653            randomizeButton.gameObject.SetActive(true);
 654
 0655            if (isSelected)
 656            {
 0657                sectionTitle.text = AVATAR_SECTION_TITLE;
 0658                ResetPreviewEmote();
 659            }
 660
 0661            emotesCustomizationDataStore.isEmotesCustomizationSelected.Set(false, notifyEvent: false);
 0662        });
 48663        sectionSelector.GetSection(EMOTES_SECTION_INDEX).onSelect.AddListener((isSelected) =>
 664        {
 0665            emotesSection.SetActive(isSelected);
 0666            randomizeButton.gameObject.SetActive(false);
 667
 0668            if (isSelected)
 669            {
 0670                sectionTitle.text = EMOTES_SECTION_TITLE;
 0671                ResetPreviewEmote();
 672            }
 673
 0674            characterPreviewController.SetFocus(CharacterPreviewController.CameraFocus.DefaultEditing);
 0675            emotesCustomizationDataStore.isEmotesCustomizationSelected.Set(true, notifyEvent: false);
 0676        });
 48677    }
 678
 679    internal void SetSectionActive(int sectionIndex, bool isActive)
 680    {
 96681        sectionSelector.GetSection(sectionIndex).SetActive(isActive);
 288682        sectionSelector.gameObject.SetActive(sectionSelector.GetAllSections().Count(x => x.IsActive()) > 1);
 96683    }
 684
 2685    public void PlayPreviewEmote(string emoteId) { characterPreviewController.PlayEmote(emoteId, (long)Time.realtimeSinc
 686
 2687    public void ResetPreviewEmote() { PlayPreviewEmote(RESET_PREVIEW_ANIMATION); }
 688
 689    public void ToggleThirdPartyCollection(string collectionId, bool isOn)
 690    {
 0691        List<IToggleComponentView> allCollectionOptions = collectionsDropdown.GetAllOptions();
 0692        foreach (IToggleComponentView collectionOption in allCollectionOptions)
 693        {
 0694            if (collectionOption.id == collectionId)
 0695                collectionOption.isOn = isOn;
 696        }
 0697    }
 698    public void ShowNoItemOfWearableCollectionWarning()
 699    {
 0700        noItemInCollectionWarning.Dismiss(true);
 0701        noItemInCollectionWarning.Show(new DCL.NotificationModel.Model
 702        {
 703            timer = 5f,
 704        });
 0705    }
 706
 707    private void ClickBlockerClicked()
 708    {
 0709        noItemInCollectionWarning.Dismiss(false);
 0710    }
 711
 712    private void UpdateAvatarModelWhenNeeded()
 713    {
 1714        if (isAvatarDirty)
 715        {
 0716            characterPreviewController.UpdateModel(avatarModelToUpdate,
 717                () =>
 718                {
 0719                    if (doneButton != null)
 0720                        doneButton.interactable = true;
 721
 0722                    loadingSpinnerGameObject?.SetActive(false);
 723
 0724                    if (!updateAvatarShouldSkipAudio)
 0725                        OnAvatarAppear?.Invoke(avatarModelToUpdate);
 726
 0727                    ClearWearablesLoadingSpinner();
 0728                    randomizeAnimator?.SetBool(RANDOMIZE_ANIMATOR_LOADING_BOOL, false);
 0729                });
 730
 0731            isAvatarDirty = false;
 732        }
 1733    }
 734}

Methods/Properties

AvatarEditorHUDView()
isOpen()
isOpen(System.Boolean)
emotesCustomizationDataStore()
Initialize()
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, 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()
UpdateAvatarModelWhenNeeded()