< 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:210
Uncovered lines:101
Coverable lines:311
Total lines:735
Line coverage:67.5% (210 of 311)
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%
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;
 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] internal GameObject web3Container;
 105    [SerializeField] internal GameObject noWeb3Container;
 106    [SerializeField] private GameObject collectiblesEmptyListContainer;
 107
 108    [Header("Skins")]
 109
 110    [SerializeField] internal GameObject skinsFeatureContainer;
 111
 112    [SerializeField] internal GameObject skinsWeb3Container;
 113
 114    [SerializeField] internal GameObject skinsMissingWeb3Container;
 115
 116    [SerializeField] internal GameObject skinsConnectWalletButtonContainer;
 117
 118    [SerializeField] private GameObject skinsPopulatedListContainer;
 119    [SerializeField] private GameObject skinsEmptyListContainer;
 120
 121    [SerializeField]
 122    internal DropdownComponentView collectionsDropdown;
 123
 124    [Header("Section Selector")]
 125    [SerializeField] internal SectionSelectorComponentView sectionSelector;
 126    [SerializeField] internal TMP_Text sectionTitle;
 127    [SerializeField] internal GameObject avatarSection;
 128    [SerializeField] internal GameObject emotesSection;
 129
 130    [SerializeField] internal UIHelper_ClickBlocker clickBlocker;
 131    [SerializeField] internal Notification noItemInCollectionWarning;
 132
 133    private static CharacterPreviewController characterPreviewController;
 134    private AvatarEditorHUDController controller;
 50135    internal readonly Dictionary<string, ItemSelector> selectorsByCategory = new Dictionary<string, ItemSelector>();
 50136    private readonly HashSet<WearableItem> wearablesWithLoadingSpinner = new HashSet<WearableItem>();
 50137    private readonly Dictionary<string, ToggleComponentModel> loadedCollectionModels = new Dictionary<string, ToggleComp
 138    private bool isAvatarDirty;
 139    private AvatarModel avatarModelToUpdate;
 140    private bool updateAvatarShouldSkipAudio;
 141
 142    public event Action<AvatarModel> OnAvatarAppear;
 143    public event Action<bool> OnSetVisibility;
 144    public event Action OnRandomize;
 145
 146    private void Awake()
 147    {
 48148        loadingSpinnerGameObject.SetActive(false);
 48149        doneButton.interactable = false; //the default state of the button should be disable until a profile has been lo
 48150        if (characterPreviewController == null)
 151        {
 48152            characterPreviewController = Instantiate(characterPreviewPrefab).GetComponent<CharacterPreviewController>();
 48153            characterPreviewController.name = "_CharacterPreviewController";
 154        }
 155
 48156        isOpen = false;
 48157        arePanelsInitialized = false;
 48158    }
 159
 160    private void Initialize(AvatarEditorHUDController controller)
 161    {
 48162        this.controller = controller;
 48163        gameObject.name = VIEW_OBJECT_NAME;
 164
 48165        randomizeButton.onClick.AddListener(OnRandomizeButton);
 48166        doneButton.onClick.AddListener(OnDoneButton);
 48167        InitializeWearableChangeEvents();
 168
 576169        foreach (var button in goToMarketplaceButtons)
 240170            button.onClick.RemoveAllListeners();
 576171        foreach (var button in goToMarketplaceButtons)
 240172            button.onClick.AddListener(controller.GoToMarketplaceOrConnectWallet);
 173
 48174        characterPreviewController.camera.enabled = false;
 175
 48176        collectionsDropdown.OnOptionSelectionChanged -= controller.ToggleThirdPartyCollection;
 48177        collectionsDropdown.OnOptionSelectionChanged += controller.ToggleThirdPartyCollection;
 178
 48179        clickBlocker.OnClicked += ClickBlockerClicked;
 180
 48181        ConfigureSectionSelector();
 48182    }
 183
 184    private void Update()
 185    {
 1186        UpdateAvatarModelWhenNeeded();
 1187    }
 188
 189    public void SetIsWeb3(bool isWeb3User)
 190    {
 103191        web3Container.SetActive(isWeb3User);
 103192        noWeb3Container.SetActive(!isWeb3User);
 103193        skinsWeb3Container.SetActive(isWeb3User);
 103194        skinsMissingWeb3Container.SetActive(!isWeb3User);
 103195    }
 196
 197    internal void InitializeNavigationEvents(bool isGuest)
 198    {
 103199        if (arePanelsInitialized)
 56200            return;
 201
 1880202        for (int i = 0; i < navigationInfos.Length; i++)
 203        {
 893204            InitializeNavigationInfo(navigationInfos[i]);
 205        }
 47206        InitializeNavigationInfo(collectiblesNavigationInfo, !isGuest);
 207
 47208        characterPreviewRotation.OnHorizontalRotation += characterPreviewController.Rotate;
 47209        arePanelsInitialized = true;
 47210    }
 211
 212    private void InitializeNavigationInfo(AvatarEditorNavigationInfo current, bool isActive)
 213    {
 940214        current.Initialize();
 215
 940216        current.toggle.isOn = isActive ? current.enabledByDefault : false;
 940217        current.canvas.gameObject.SetActive(isActive ? current.enabledByDefault : false);
 218
 940219        current.toggle.onValueChanged.AddListener((on) =>
 220        {
 47221            current.canvas.gameObject.SetActive(@on);
 47222            characterPreviewController.SetFocus(current.focus);
 47223        });
 940224    }
 225
 226    private void InitializeNavigationInfo(AvatarEditorNavigationInfo current)
 227    {
 893228        InitializeNavigationInfo(current, true);
 893229    }
 230
 231    private void InitializeWearableChangeEvents()
 232    {
 48233        int nPairs = wearableGridPairs.Length;
 1728234        for (int i = 0; i < nPairs; i++)
 235        {
 816236            wearableGridPairs[i].selector.OnItemClicked += controller.WearableClicked;
 816237            wearableGridPairs[i].selector.OnSellClicked += controller.SellCollectible;
 816238            selectorsByCategory.Add(wearableGridPairs[i].categoryFilter, wearableGridPairs[i].selector);
 239        }
 240
 48241        collectiblesItemSelector.OnItemClicked += controller.WearableClicked;
 48242        collectiblesItemSelector.OnSellClicked += controller.SellCollectible;
 243
 48244        skinColorSelector.OnColorSelectorChange += controller.SkinColorClicked;
 48245        eyeColorPickerComponent.OnColorChanged += controller.EyesColorClicked;
 48246        hairColorPickerComponent.OnColorChanged += controller.HairColorClicked;
 48247        facialHairColorPickerComponent.OnColorChanged += controller.HairColorClicked;
 48248        eyeBrowsColorPickerComponent.OnColorChanged += controller.HairColorClicked;
 48249    }
 250
 251    internal static AvatarEditorHUDView Create(AvatarEditorHUDController controller)
 252    {
 48253        var view = Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<AvatarEditorHUDView>();
 48254        view.Initialize(controller);
 48255        return view;
 256    }
 257
 258    public void UpdateSelectedBody(WearableItem bodyShape)
 259    {
 2232260        for (int i = 0; i < wearableGridPairs.Length; i++)
 261        {
 1054262            if (wearableGridPairs[i].categoryFilter == WearableLiterals.Categories.BODY_SHAPE)
 263            {
 62264                wearableGridPairs[i].selector.UnselectAll();
 62265                wearableGridPairs[i].selector.Select(bodyShape.id);
 62266            }
 267            else
 268            {
 992269                wearableGridPairs[i].selector.SetBodyShape(bodyShape.id);
 270            }
 271        }
 272
 62273        collectiblesItemSelector.SetBodyShape(bodyShape.id);
 62274    }
 275
 276    public void EquipWearable(WearableItem wearable)
 277    {
 1090278        selectorsByCategory[wearable.data.category].Select(wearable.id);
 1090279        SetWearableLoadingSpinner(wearable, true);
 1090280        collectiblesItemSelector.Select(wearable.id);
 1090281    }
 282
 283    public void UnequipWearable(WearableItem wearable)
 284    {
 464285        selectorsByCategory[wearable.data.category].Unselect(wearable.id);
 464286        SetWearableLoadingSpinner(wearable, false);
 464287        collectiblesItemSelector.Unselect(wearable.id);
 464288    }
 289
 290    internal void SetWearableLoadingSpinner(WearableItem wearable, bool isActive)
 291    {
 1554292        selectorsByCategory[wearable.data.category].SetWearableLoadingSpinner(wearable.id, isActive);
 1554293        collectiblesItemSelector.SetWearableLoadingSpinner(wearable.id, isActive);
 1554294        if (isActive)
 1090295            wearablesWithLoadingSpinner.Add(wearable);
 296        else
 464297            wearablesWithLoadingSpinner.Remove(wearable);
 464298    }
 299
 300    internal void ClearWearablesLoadingSpinner()
 301    {
 0302        foreach (WearableItem wearable in wearablesWithLoadingSpinner)
 303        {
 0304            selectorsByCategory[wearable.data.category].SetWearableLoadingSpinner(wearable.id, false);
 0305            collectiblesItemSelector.SetWearableLoadingSpinner(wearable.id, false);
 306        }
 307
 0308        wearablesWithLoadingSpinner.Clear();
 0309    }
 310
 311    public void SelectHairColor(Color hairColor)
 312    {
 107313        hairColorPickerComponent.SetColorSelector(hairColor);
 107314        hairColorPickerComponent.UpdateSliderValues(hairColor);
 107315        eyeBrowsColorPickerComponent.SetColorSelector(hairColor);
 107316        eyeBrowsColorPickerComponent.UpdateSliderValues(hairColor);
 107317        facialHairColorPickerComponent.SetColorSelector(hairColor);
 107318        facialHairColorPickerComponent.UpdateSliderValues(hairColor);
 107319    }
 320
 321    public Color GetRandomColor()
 322    {
 2323        return Color.HSVToRGB(UnityEngine.Random.Range(0, 1f), UnityEngine.Random.Range(0, 1f), UnityEngine.Random.Range
 324    }
 325
 326    public void SelectSkinColor(Color skinColor)
 327    {
 106328        skinColorSelector.Select(skinColor);
 106329    }
 330
 331    public void SelectEyeColor(Color eyesColor)
 332    {
 107333        eyeColorPickerComponent.SetColorSelector(eyesColor);
 107334        eyeColorPickerComponent.UpdateSliderValues(eyesColor);
 107335    }
 336
 337    public void SetColors(List<Color> skinColors, List<Color> hairColors, List<Color> eyeColors)
 338    {
 48339        skinColorSelector.Populate(skinColors);
 48340        eyeColorPickerComponent.SetColorList(eyeColors);
 48341        hairColorPickerComponent.SetColorList(hairColors);
 48342        eyeBrowsColorPickerComponent.SetColorList(hairColors);
 48343        facialHairColorPickerComponent.SetColorList(hairColors);
 48344    }
 345
 346    public void UnselectAllWearables()
 347    {
 3708348        for (int i = 0; i < wearableGridPairs.Length; i++)
 349        {
 1751350            if (wearableGridPairs[i].categoryFilter != WearableLiterals.Categories.BODY_SHAPE)
 351            {
 1648352                wearableGridPairs[i].selector.UnselectAll();
 353            }
 354        }
 355
 103356        collectiblesItemSelector.UnselectAll();
 103357    }
 358
 359    public void UpdateAvatarPreview(AvatarModel avatarModel, bool skipAudio)
 360    {
 124361        if (avatarModel?.wearables == null)
 0362            return;
 363
 364        // We delay the updating of the avatar 1 frame to disengage from the kernel message flow
 365        // otherwise the cancellation of the updating task throws an exception that is catch by
 366        // kernel setthrew method, which floods the analytics.
 367        // Also it updates just once if its called many times in a row
 124368        isAvatarDirty = true;
 124369        avatarModelToUpdate = avatarModel;
 124370        updateAvatarShouldSkipAudio = skipAudio;
 371
 124372        doneButton.interactable = false;
 124373        loadingSpinnerGameObject.SetActive(true);
 124374    }
 375
 376    public void AddWearable(WearableItem wearableItem, int amount,
 377        Func<WearableItem, bool> hideOtherWearablesToastStrategy,
 378        Func<WearableItem, bool> replaceOtherWearablesToastStrategy,
 379        Func<WearableItem, bool> incompatibleWearableToastStrategy)
 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].AddWearable(
 393            wearableItem,
 394            collectionName,
 395            amount,
 396            hideOtherWearablesToastStrategy,
 397            replaceOtherWearablesToastStrategy,
 398            incompatibleWearableToastStrategy);
 399
 4221400        if (wearableItem.IsCollectible() || wearableItem.IsFromThirdPartyCollection)
 401        {
 21402            collectiblesItemSelector.AddWearable(
 403                wearableItem,
 404                collectionName,
 405                amount,
 406                hideOtherWearablesToastStrategy,
 407                replaceOtherWearablesToastStrategy,
 408                incompatibleWearableToastStrategy);
 409        }
 4221410    }
 411
 412    public void RefreshSelectorsSize()
 413    {
 162414        using (var iterator = selectorsByCategory.GetEnumerator())
 415        {
 2916416            while (iterator.MoveNext())
 417            {
 2754418                iterator.Current.Value.UpdateSelectorLayout();
 419            }
 162420        }
 421
 162422        collectiblesItemSelector.UpdateSelectorLayout();
 162423    }
 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].RemoveWearable(wearableItem.id);
 0452        if (wearableItem.IsCollectible() || wearableItem.IsFromThirdPartyCollection)
 0453            collectiblesItemSelector.RemoveWearable(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.RemoveAllWearables();
 463            }
 151464        }
 465
 151466        collectiblesItemSelector.RemoveAllWearables();
 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;
 544        }
 545
 48546        if (skinColorSelector != null)
 48547            skinColorSelector.OnColorSelectorChange -= controller.SkinColorClicked;
 48548        if (eyeColorPickerComponent != null)
 48549            eyeColorPickerComponent.OnColorChanged -= controller.EyesColorClicked;
 48550        if (hairColorPickerComponent != null)
 48551            hairColorPickerComponent.OnColorChanged -= controller.HairColorClicked;
 48552        if (facialHairColorPickerComponent != null)
 48553            facialHairColorPickerComponent.OnColorChanged -= controller.HairColorClicked;
 48554        if (eyeBrowsColorPickerComponent != null)
 48555            eyeBrowsColorPickerComponent.OnColorChanged -= controller.HairColorClicked;
 556
 48557        if (this != null)
 48558            Destroy(gameObject);
 559
 48560        if (characterPreviewController != null)
 561        {
 48562            Destroy(characterPreviewController.gameObject);
 48563            characterPreviewController = null;
 564        }
 565
 48566        collectionsDropdown.OnOptionSelectionChanged -= controller.ToggleThirdPartyCollection;
 48567        collectionsDropdown.Dispose();
 568
 48569        sectionSelector.GetSection(AVATAR_SECTION_INDEX).onSelect.RemoveAllListeners();
 48570        sectionSelector.GetSection(EMOTES_SECTION_INDEX).onSelect.RemoveAllListeners();
 571
 48572        clickBlocker.OnClicked -= ClickBlockerClicked;
 48573    }
 574
 575    public void SetAsFullScreenMenuMode(Transform parentTransform)
 576    {
 48577        if (parentTransform == null)
 48578            return;
 579
 0580        transform.SetParent(parentTransform);
 0581        transform.localScale = Vector3.one;
 582
 0583        RectTransform rectTransform = transform as RectTransform;
 0584        rectTransform.anchorMin = Vector2.zero;
 0585        rectTransform.anchorMax = Vector2.one;
 0586        rectTransform.pivot = new Vector2(0.5f, 0.5f);
 0587        rectTransform.localPosition = Vector2.zero;
 0588        rectTransform.offsetMax = Vector2.zero;
 0589        rectTransform.offsetMin = Vector2.zero;
 0590    }
 591
 592    public void OnPointerDown(PointerEventData eventData)
 593    {
 0594        if (eventData.pointerPressRaycast.gameObject != eyeColorPickerComponent.gameObject &&
 595            eventData.pointerPressRaycast.gameObject != hairColorPickerComponent.gameObject &&
 596            eventData.pointerPressRaycast.gameObject != eyeBrowsColorPickerComponent.gameObject &&
 597            eventData.pointerPressRaycast.gameObject != facialHairColorPickerComponent.gameObject)
 598        {
 0599            eyeColorPickerComponent.SetActive(false);
 0600            hairColorPickerComponent.SetActive(false);
 0601            eyeBrowsColorPickerComponent.SetActive(false);
 0602            facialHairColorPickerComponent.SetActive(false);
 603        }
 0604    }
 605
 606    public void LoadCollectionsDropdown(Collection[] collections)
 607    {
 0608        List<ToggleComponentModel> collectionsToAdd = new List<ToggleComponentModel>();
 0609        foreach (var collection in collections)
 610        {
 0611            ToggleComponentModel newCollectionModel = new ToggleComponentModel
 612            {
 613                id = collection.urn,
 614                text = collection.name,
 615                isOn = false,
 616                isTextActive = true
 617            };
 618
 0619            collectionsToAdd.Add(newCollectionModel);
 0620            loadedCollectionModels.Add(collection.urn, newCollectionModel);
 621        }
 622
 0623        collectionsDropdown.SetOptions(collectionsToAdd);
 0624    }
 625
 626    public void BlockCollectionsDropdown(bool isBlocked)
 627    {
 1628        collectionsDropdown.SetLoadingActive(isBlocked);
 1629    }
 630
 631    public void ShowSkinPopulatedList(bool show)
 632    {
 151633        skinsPopulatedListContainer.SetActive(show);
 151634        skinsEmptyListContainer.SetActive(!show);
 151635        skinsConnectWalletButtonContainer.SetActive(show);
 151636    }
 637
 638    public void ShowCollectiblesPopulatedList(bool show)
 639    {
 151640        collectiblesEmptyListContainer.SetActive(!show);
 151641    }
 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
 735}

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], System.Func[WearableItem,Boolean])
RefreshSelectorsSize()
GetWearableCollectionName(WearableItem)
RemoveWearable(WearableItem)
RemoveAllWearables()
OnRandomizeButton()
OnDoneButton()
TakeSnapshotsAfterStopPreviewAnimation()
OnSnapshotsReady(UnityEngine.Texture2D, UnityEngine.Texture2D)
OnSnapshotsFailed()
SetVisibility(System.Boolean)
CleanUp()
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()