| | 1 | | using AvatarSystem; |
| | 2 | | using Cysharp.Threading.Tasks; |
| | 3 | | using DCL.Tasks; |
| | 4 | | using DG.Tweening; |
| | 5 | | using MainScripts.DCL.Controllers.HUD.CharacterPreview; |
| | 6 | | using System; |
| | 7 | | using System.Collections.Generic; |
| | 8 | | using System.Threading; |
| | 9 | | using TMPro; |
| | 10 | | using UIComponents.Scripts.Components; |
| | 11 | | using UnityEngine; |
| | 12 | | using UnityEngine.EventSystems; |
| | 13 | | using UnityEngine.UI; |
| | 14 | |
|
| | 15 | | namespace DCL.Backpack |
| | 16 | | { |
| | 17 | | public class BackpackEditorHUDV2ComponentView : BaseComponentView<BackpackEditorHUDModel>, IBackpackEditorHUDView, I |
| | 18 | | { |
| | 19 | | private const string SIGN_UP_HEADER_TITLE_FOR_FISRT_STEP = "Customize Your Avatar"; |
| | 20 | | private const string SIGN_UP_HEADER_TITLE_FOR_SECOND_STEP = "Final Details"; |
| | 21 | |
|
| | 22 | | public event Action<Color> OnColorChanged; |
| | 23 | | public event Action OnColorPickerToggle; |
| | 24 | | public event Action OnContinueSignup; |
| | 25 | | public event Action OnAvatarUpdated; |
| | 26 | | public event Action OnOutfitsOpened; |
| | 27 | | public event Action OnVRMExport; |
| | 28 | | public event Action OnVRMDetailsOpened; |
| | 29 | | public event Action OnVRMDetailsClosed; |
| | 30 | | public event Action<SignUpStage> OnSignUpBackClicked; |
| | 31 | |
|
| | 32 | | private const int AVATAR_SECTION_INDEX = 0; |
| | 33 | | private const int EMOTES_SECTION_INDEX = 1; |
| | 34 | | private const int MS_TO_RESET_PREVIEW_ANIMATION = 200; |
| | 35 | |
|
| | 36 | | [SerializeField] internal SectionSelectorComponentView sectionSelector; |
| | 37 | | [SerializeField] internal GameObject wearablesSection; |
| | 38 | | [SerializeField] internal CanvasGroup wearablesSectionCanvasGroup; |
| | 39 | | [SerializeField] internal Image wearablesSectionBackground; |
| | 40 | | [SerializeField] internal GameObject emotesSection; |
| | 41 | | [SerializeField] private BackpackPreviewPanel backpackPreviewPanel; |
| | 42 | | [SerializeField] private WearableGridComponentView wearableGridComponentView; |
| | 43 | | [SerializeField] private AvatarSlotsView avatarSlotsView; |
| | 44 | | [SerializeField] internal ColorPickerComponentView colorPickerComponentView; |
| | 45 | | [SerializeField] internal ColorPresetsSO colorPresetsSO; |
| | 46 | | [SerializeField] internal ColorPresetsSO skinColorPresetsSO; |
| | 47 | | [SerializeField] internal Color selectedOutfitButtonColor; |
| | 48 | | [SerializeField] private BackpackFiltersComponentView backpackFiltersComponentView; |
| | 49 | | [SerializeField] private OutfitsSectionComponentView outfitsSectionComponentView; |
| | 50 | | [SerializeField] internal Button saveAvatarButton; |
| | 51 | | [SerializeField] internal GameObject normalSection; |
| | 52 | | [SerializeField] internal GameObject outfitSection; |
| | 53 | | [SerializeField] internal GameObject vrmDetailsSection; |
| | 54 | | [SerializeField] internal Button outfitButton; |
| | 55 | | [SerializeField] internal Image outfitButtonIcon; |
| | 56 | | [SerializeField] internal GameObject background; |
| | 57 | | [SerializeField] internal GameObject hints; |
| | 58 | |
|
| | 59 | | [Header("VRM Export")] |
| | 60 | | [SerializeField] internal Button vrmExportButton; |
| | 61 | | [SerializeField] internal TooltipComponentView vrmExportTooltipComponentView; |
| | 62 | | [SerializeField] internal GameObject vrmWarningBubble; |
| | 63 | | [SerializeField] internal RectTransform vrmExportedToast; |
| | 64 | | [SerializeField] private VRMDetailsComponentView vrmDetailsComponentView; |
| | 65 | |
|
| | 66 | | [Header("Sign Up Mode")] |
| | 67 | | [SerializeField] internal GameObject signUpHeader; |
| | 68 | | [SerializeField] internal TMP_Text signUpHeaderTitle; |
| | 69 | | [SerializeField] internal GameObject backgroundForSignUp; |
| | 70 | | [SerializeField] internal Button backButton; |
| | 71 | | [SerializeField] internal Button nextButton; |
| | 72 | | [SerializeField] internal GameObject[] objectsToDeactivateInSignUpMode; |
| | 73 | |
|
| | 74 | | [Header("SignUp Mode Transitions")] |
| | 75 | | [SerializeField] internal RectTransform wearablesBackgroundForSignUp; |
| | 76 | | [SerializeField] internal CanvasGroup wearablesBackgroundForSignUpCanvasGroup; |
| 18 | 77 | | [SerializeField] internal Ease transitionEase = Ease.InOutExpo; |
| 18 | 78 | | [SerializeField] internal float transitionDuration = 0.5f; |
| 18 | 79 | | [SerializeField] internal float transitionDistance = 1800f; |
| | 80 | |
|
| 0 | 81 | | public IReadOnlyList<SkinnedMeshRenderer> originalVisibleRenderers => backpackPreviewPanel?.originalVisibleRende |
| 0 | 82 | | public IAvatarEmotesController EmotesController => backpackPreviewPanel?.EmotesController; |
| 0 | 83 | | public override bool isVisible => gameObject.activeInHierarchy; |
| 0 | 84 | | public Transform EmotesSectionTransform => emotesSection.transform; |
| 0 | 85 | | public WearableGridComponentView WearableGridComponentView => wearableGridComponentView; |
| 0 | 86 | | public AvatarSlotsView AvatarSlotsView => avatarSlotsView; |
| 0 | 87 | | public BackpackFiltersComponentView BackpackFiltersComponentView => backpackFiltersComponentView; |
| 0 | 88 | | public OutfitsSectionComponentView OutfitsSectionComponentView => outfitsSectionComponentView; |
| 0 | 89 | | public IVRMDetailsComponentView VrmDetailsComponentView => vrmDetailsComponentView; |
| | 90 | |
|
| 54 | 91 | | private DataStore_EmotesCustomization emotesCustomizationDataStore => DataStore.i.emotesCustomization; |
| | 92 | | private Transform thisTransform; |
| | 93 | | private bool isAvatarDirty; |
| | 94 | | private AvatarModel avatarModelToUpdate; |
| 18 | 95 | | private CancellationTokenSource updateAvatarCts = new (); |
| 18 | 96 | | private CancellationTokenSource snapshotsCts = new (); |
| | 97 | | private SignUpStage currentStage; |
| | 98 | | private Vector2 originalAnchorPositionOfWearablesBackgroundForSignUp; |
| | 99 | | private Vector2 originalAnchorPositionOfWearablesSection; |
| | 100 | | private bool vrmWarningEnabled; |
| | 101 | |
|
| | 102 | | public override void Awake() |
| | 103 | | { |
| 17 | 104 | | base.Awake(); |
| | 105 | |
|
| 17 | 106 | | thisTransform = transform; |
| 17 | 107 | | backpackPreviewPanel.SetLoadingActive(false); |
| 17 | 108 | | originalAnchorPositionOfWearablesBackgroundForSignUp = wearablesBackgroundForSignUp.anchoredPosition; |
| 17 | 109 | | originalAnchorPositionOfWearablesSection = ((RectTransform)wearablesSection.transform).anchoredPosition; |
| 17 | 110 | | saveAvatarButton.onClick.AddListener(() => OnContinueSignup?.Invoke()); |
| 17 | 111 | | nextButton.onClick.AddListener(() => OnContinueSignup?.Invoke()); |
| 17 | 112 | | backButton.onClick.AddListener(() => OnSignUpBackClicked?.Invoke(currentStage)); |
| 17 | 113 | | ToggleNormalSection(); |
| 17 | 114 | | } |
| | 115 | |
|
| | 116 | | public void Initialize( |
| | 117 | | ICharacterPreviewFactory characterPreviewFactory, |
| | 118 | | IPreviewCameraRotationController avatarPreviewRotationController, |
| | 119 | | IPreviewCameraPanningController avatarPreviewPanningController, |
| | 120 | | IPreviewCameraZoomController avatarPreviewZoomController) |
| | 121 | | { |
| 17 | 122 | | ConfigureSectionSelector(); |
| | 123 | |
|
| 17 | 124 | | backpackPreviewPanel.Initialize( |
| | 125 | | characterPreviewFactory, |
| | 126 | | avatarPreviewRotationController, |
| | 127 | | avatarPreviewPanningController, |
| | 128 | | avatarPreviewZoomController); |
| | 129 | |
|
| 17 | 130 | | colorPickerComponentView.OnColorChanged += OnColorPickerColorChanged; |
| 17 | 131 | | colorPickerComponentView.OnColorPickerToggle += ColorPickerToggle; |
| | 132 | |
|
| 17 | 133 | | outfitButton.onClick.RemoveAllListeners(); |
| 17 | 134 | | outfitButton.onClick.AddListener(ToggleOutfitSection); |
| | 135 | |
|
| 17 | 136 | | vrmExportButton.onClick.RemoveAllListeners(); |
| 17 | 137 | | vrmExportButton.onClick.AddListener(OnVRMExportButtonClicked); |
| | 138 | |
|
| 17 | 139 | | vrmDetailsComponentView.OnVRMExportButtonPressed += OnDetailsPanelVRMExportButtonClicked; |
| 17 | 140 | | vrmDetailsComponentView.OnBackButtonPressed += BackFromDetails; |
| 17 | 141 | | outfitsSectionComponentView.OnBackButtonPressed += ToggleNormalSection; |
| 17 | 142 | | } |
| | 143 | |
|
| | 144 | | private void BackFromDetails() |
| | 145 | | { |
| 0 | 146 | | ToggleNormalSection(); |
| 0 | 147 | | OnVRMDetailsClosed?.Invoke(); |
| 0 | 148 | | } |
| | 149 | |
|
| | 150 | | private void OnVRMExportButtonClicked() |
| | 151 | | { |
| 0 | 152 | | if (vrmDetailsSection.activeInHierarchy) return; |
| | 153 | |
|
| 0 | 154 | | if (vrmWarningEnabled) |
| | 155 | | { |
| 0 | 156 | | SetWarningForVRMExportButton(false); |
| 0 | 157 | | ToggleVRMDetailsSection(); |
| | 158 | | } |
| | 159 | | else |
| 0 | 160 | | OnVRMExport?.Invoke(); |
| 0 | 161 | | } |
| | 162 | |
|
| | 163 | | private void OnDetailsPanelVRMExportButtonClicked() |
| | 164 | | { |
| 0 | 165 | | if (vrmWarningEnabled) return; |
| | 166 | |
|
| 0 | 167 | | OnVRMExport?.Invoke(); |
| 0 | 168 | | } |
| | 169 | |
|
| | 170 | | public void SetOutfitsEnabled(bool isEnabled) => |
| 0 | 171 | | outfitButton.gameObject.SetActive(isEnabled); |
| | 172 | |
|
| | 173 | | private void ToggleOutfitSection() |
| | 174 | | { |
| 0 | 175 | | if (outfitSection.activeInHierarchy) |
| 0 | 176 | | ToggleNormalSection(); |
| | 177 | | else |
| | 178 | | { |
| 0 | 179 | | outfitSection.SetActive(true); |
| 0 | 180 | | normalSection.SetActive(false); |
| 0 | 181 | | vrmDetailsSection.SetActive(false); |
| 0 | 182 | | outfitButton.image.color = selectedOutfitButtonColor; |
| 0 | 183 | | outfitButtonIcon.color = Color.white; |
| 0 | 184 | | vrmExportButton.image.color = Color.white; |
| 0 | 185 | | OnOutfitsOpened?.Invoke(); |
| | 186 | | } |
| 0 | 187 | | } |
| | 188 | |
|
| | 189 | | private void ToggleNormalSection() |
| | 190 | | { |
| 18 | 191 | | normalSection.SetActive(true); |
| 18 | 192 | | outfitSection.SetActive(false); |
| 18 | 193 | | vrmDetailsSection.SetActive(false); |
| 18 | 194 | | outfitButton.image.color = Color.white; |
| 18 | 195 | | outfitButtonIcon.color = Color.black; |
| 18 | 196 | | vrmExportButton.image.color = Color.white; |
| 18 | 197 | | } |
| | 198 | |
|
| | 199 | | private void ToggleVRMDetailsSection() |
| | 200 | | { |
| 0 | 201 | | vrmDetailsSection.SetActive(true); |
| 0 | 202 | | outfitSection.SetActive(false); |
| 0 | 203 | | normalSection.SetActive(false); |
| 0 | 204 | | vrmExportButton.image.color = selectedOutfitButtonColor; |
| 0 | 205 | | OnVRMDetailsOpened?.Invoke(); |
| 0 | 206 | | } |
| | 207 | |
|
| | 208 | | private void Update() => |
| 3 | 209 | | UpdateAvatarModelWhenNeeded(); |
| | 210 | |
|
| | 211 | | public override void Dispose() |
| | 212 | | { |
| 34 | 213 | | base.Dispose(); |
| | 214 | |
|
| 34 | 215 | | updateAvatarCts.SafeCancelAndDispose(); |
| 34 | 216 | | updateAvatarCts = null; |
| | 217 | |
|
| 34 | 218 | | snapshotsCts.SafeCancelAndDispose(); |
| 34 | 219 | | snapshotsCts = null; |
| | 220 | |
|
| 34 | 221 | | sectionSelector.GetSection(AVATAR_SECTION_INDEX).onSelect.RemoveAllListeners(); |
| 34 | 222 | | sectionSelector.GetSection(EMOTES_SECTION_INDEX).onSelect.RemoveAllListeners(); |
| 34 | 223 | | emotesCustomizationDataStore.isEmotesCustomizationSelected.OnChange -= OnEmotesCustomizationSelected; |
| 34 | 224 | | backpackPreviewPanel.Dispose(); |
| | 225 | |
|
| 34 | 226 | | colorPickerComponentView.OnColorChanged -= OnColorPickerColorChanged; |
| 34 | 227 | | colorPickerComponentView.OnColorPickerToggle -= ColorPickerToggle; |
| | 228 | |
|
| 34 | 229 | | outfitsSectionComponentView.OnBackButtonPressed -= ToggleNormalSection; |
| 34 | 230 | | outfitButton.onClick.RemoveAllListeners(); |
| | 231 | |
|
| 34 | 232 | | vrmExportButton.onClick.RemoveAllListeners(); |
| 34 | 233 | | vrmDetailsComponentView.OnVRMExportButtonPressed -= OnDetailsPanelVRMExportButtonClicked; |
| 34 | 234 | | vrmDetailsComponentView.OnBackButtonPressed -= BackFromDetails; |
| 34 | 235 | | } |
| | 236 | |
|
| | 237 | | public static BackpackEditorHUDV2ComponentView Create() => |
| 17 | 238 | | Instantiate(Resources.Load<BackpackEditorHUDV2ComponentView>("BackpackEditorHUDV2")); |
| | 239 | |
|
| | 240 | | public override void Show(bool instant = false) |
| | 241 | | { |
| 1 | 242 | | gameObject.SetActive(true); |
| 1 | 243 | | backpackPreviewPanel.SetPreviewEnabled(true); |
| 1 | 244 | | } |
| | 245 | |
|
| | 246 | | public override void Hide(bool instant = false) |
| | 247 | | { |
| 1 | 248 | | ToggleNormalSection(); |
| 1 | 249 | | gameObject.SetActive(false); |
| 1 | 250 | | backpackPreviewPanel.SetPreviewEnabled(false); |
| 1 | 251 | | colorPickerComponentView.SetActive(false); |
| 1 | 252 | | } |
| | 253 | |
|
| 0 | 254 | | public override void RefreshControl() { } |
| | 255 | |
|
| | 256 | | public void SetAsFullScreenMenuMode(Transform parentTransform) |
| | 257 | | { |
| 0 | 258 | | if (parentTransform == null) |
| 0 | 259 | | return; |
| | 260 | |
|
| 0 | 261 | | thisTransform.SetParent(parentTransform); |
| 0 | 262 | | thisTransform.localScale = Vector3.one; |
| | 263 | |
|
| 0 | 264 | | RectTransform rectTransform = thisTransform as RectTransform; |
| 0 | 265 | | if (rectTransform == null) return; |
| 0 | 266 | | rectTransform.anchorMin = Vector2.zero; |
| 0 | 267 | | rectTransform.anchorMax = Vector2.one; |
| 0 | 268 | | rectTransform.pivot = new Vector2(0.5f, 0.5f); |
| 0 | 269 | | rectTransform.localPosition = Vector2.zero; |
| 0 | 270 | | rectTransform.offsetMax = Vector2.zero; |
| 0 | 271 | | rectTransform.offsetMin = Vector2.zero; |
| 0 | 272 | | } |
| | 273 | |
|
| | 274 | | public void PlayPreviewEmote(string emoteId) => |
| 1 | 275 | | backpackPreviewPanel.PlayPreviewEmote(emoteId); |
| | 276 | |
|
| | 277 | | public void PlayPreviewEmote(string emoteId, long timestamp) |
| | 278 | | { |
| 1 | 279 | | if (avatarModelToUpdate != null) |
| 0 | 280 | | avatarModelToUpdate.expressionTriggerTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); |
| | 281 | |
|
| 1 | 282 | | backpackPreviewPanel.PlayPreviewEmote(emoteId, timestamp); |
| 1 | 283 | | } |
| | 284 | |
|
| | 285 | | public void UpdateAvatarPreview(AvatarModel avatarModel) |
| | 286 | | { |
| 1 | 287 | | if (avatarModel?.wearables == null) |
| 0 | 288 | | return; |
| | 289 | |
|
| | 290 | | // We delay the updating of the avatar 1 frame to disengage from the kernel message flow |
| | 291 | | // otherwise the cancellation of the updating task throws an exception that is catch by |
| | 292 | | // kernel setthrew method, which floods the analytics. |
| | 293 | | // Also it updates just once if its called many times in a row |
| 1 | 294 | | isAvatarDirty = true; |
| 1 | 295 | | avatarModelToUpdate = avatarModel; |
| | 296 | |
|
| 1 | 297 | | backpackPreviewPanel.SetLoadingActive(true); |
| 1 | 298 | | } |
| | 299 | |
|
| | 300 | | public void SetAvatarPreviewFocus(PreviewCameraFocus focus, bool useTransition = true) => |
| 6 | 301 | | backpackPreviewPanel.SetFocus(focus, useTransition); |
| | 302 | |
|
| | 303 | | public void TakeSnapshotsAfterStopPreviewAnimation(IBackpackEditorHUDView.OnSnapshotsReady onSuccess, Action onF |
| | 304 | | { |
| | 305 | | async UniTaskVoid TakeSnapshotsAfterStopPreviewAnimationAsync(CancellationToken ct) |
| | 306 | | { |
| 0 | 307 | | ResetPreviewPanel(); |
| 0 | 308 | | await UniTask.Delay(MS_TO_RESET_PREVIEW_ANIMATION, cancellationToken: ct); |
| | 309 | |
|
| 0 | 310 | | backpackPreviewPanel.TakeSnapshots( |
| 0 | 311 | | (face256, body) => onSuccess?.Invoke(face256, body), |
| 0 | 312 | | () => onFailed?.Invoke()); |
| 0 | 313 | | } |
| | 314 | |
|
| 0 | 315 | | snapshotsCts = snapshotsCts.SafeRestart(); |
| 0 | 316 | | TakeSnapshotsAfterStopPreviewAnimationAsync(snapshotsCts.Token).Forget(); |
| 0 | 317 | | } |
| | 318 | |
|
| | 319 | | public void SetColorPickerVisibility(bool isActive) => |
| 2 | 320 | | colorPickerComponentView.gameObject.SetActive(isActive); |
| | 321 | |
|
| | 322 | | public void SetColorPickerAsSkinMode(bool isSkinMode) |
| | 323 | | { |
| 2 | 324 | | colorPickerComponentView.SetShowOnlyPresetColors(isSkinMode); |
| 2 | 325 | | colorPickerComponentView.SetColorList(isSkinMode ? skinColorPresetsSO.colors : colorPresetsSO.colors); |
| 2 | 326 | | } |
| | 327 | |
|
| | 328 | | public void UpdateHideUnhideStatus(string slotCategory, HashSet<string> forceRender) => |
| 0 | 329 | | avatarSlotsView.SetHideUnhideStatus(slotCategory, forceRender.Contains(slotCategory)); |
| | 330 | |
|
| | 331 | | public void SetColorPickerValue(Color color) |
| | 332 | | { |
| 1 | 333 | | colorPickerComponentView.SetColorSelector(color); |
| 1 | 334 | | colorPickerComponentView.UpdateSliderValues(color); |
| 1 | 335 | | } |
| | 336 | |
|
| | 337 | | public void ShowContinueSignup() => |
| 0 | 338 | | saveAvatarButton.gameObject.SetActive(true); |
| | 339 | |
|
| | 340 | | public void HideContinueSignup() => |
| 0 | 341 | | saveAvatarButton.gameObject.SetActive(false); |
| | 342 | |
|
| | 343 | | public void SetVRMButtonActive(bool enabled) |
| | 344 | | { |
| 0 | 345 | | vrmExportButton.gameObject.SetActive(enabled); |
| 0 | 346 | | } |
| | 347 | |
|
| | 348 | | public void SetVRMButtonEnabled(bool enabled) |
| | 349 | | { |
| 0 | 350 | | vrmExportButton.enabled = enabled; |
| 0 | 351 | | } |
| | 352 | |
|
| | 353 | | public void SetVRMSuccessToastActive(bool active) |
| | 354 | | { |
| 0 | 355 | | vrmExportedToast.gameObject.SetActive(active); |
| 0 | 356 | | } |
| | 357 | |
|
| | 358 | | public void SetWarningForVRMExportButton(bool enable) |
| | 359 | | { |
| 0 | 360 | | vrmWarningEnabled = enable; |
| 0 | 361 | | if (vrmWarningEnabled) |
| | 362 | | { |
| 0 | 363 | | vrmWarningBubble.SetActive(true); |
| 0 | 364 | | vrmExportTooltipComponentView.isViewEnabled = true; |
| | 365 | | } |
| | 366 | | else |
| | 367 | | { |
| 0 | 368 | | vrmWarningBubble.SetActive(false); |
| 0 | 369 | | vrmExportTooltipComponentView.isViewEnabled = false; |
| | 370 | | } |
| 0 | 371 | | } |
| | 372 | |
|
| | 373 | | public void SetSignUpModeActive(bool isActive) |
| | 374 | | { |
| 0 | 375 | | signUpHeader.SetActive(isActive); |
| 0 | 376 | | backgroundForSignUp.SetActive(isActive); |
| 0 | 377 | | background.SetActive(!isActive); |
| 0 | 378 | | wearablesSectionBackground.enabled = !isActive; |
| | 379 | |
|
| 0 | 380 | | foreach (GameObject go in objectsToDeactivateInSignUpMode) |
| 0 | 381 | | go.SetActive(!isActive); |
| 0 | 382 | | } |
| | 383 | |
|
| | 384 | | public void SetSignUpStage(SignUpStage stage) |
| | 385 | | { |
| 0 | 386 | | currentStage = stage; |
| 0 | 387 | | nextButton.gameObject.SetActive(stage == SignUpStage.CustomizeAvatar); |
| 0 | 388 | | signUpHeaderTitle.text = stage == SignUpStage.CustomizeAvatar ? SIGN_UP_HEADER_TITLE_FOR_FISRT_STEP : SIGN_U |
| 0 | 389 | | hints.SetActive(stage == SignUpStage.CustomizeAvatar); |
| 0 | 390 | | PlayTransitionAnimation(stage); |
| 0 | 391 | | } |
| | 392 | |
|
| | 393 | | public void OnPointerDown(PointerEventData eventData) |
| | 394 | | { |
| 0 | 395 | | if (eventData.pointerPressRaycast.gameObject != colorPickerComponentView.gameObject) |
| 0 | 396 | | colorPickerComponentView.SetActive(false); |
| 0 | 397 | | } |
| | 398 | |
|
| | 399 | | private void ConfigureSectionSelector() |
| | 400 | | { |
| 17 | 401 | | sectionSelector.GetSection(AVATAR_SECTION_INDEX) |
| | 402 | | .onSelect.AddListener((isSelected) => |
| | 403 | | { |
| 3 | 404 | | wearablesSection.SetActive(isSelected); |
| | 405 | |
|
| 3 | 406 | | if (isSelected) |
| 1 | 407 | | ResetPreviewPanel(); |
| 3 | 408 | | }); |
| | 409 | |
|
| 17 | 410 | | sectionSelector.GetSection(EMOTES_SECTION_INDEX) |
| | 411 | | .onSelect.AddListener((isSelected) => |
| | 412 | | { |
| 3 | 413 | | emotesCustomizationDataStore.isEmotesCustomizationSelected.Set(isSelected); |
| | 414 | |
|
| 3 | 415 | | emotesSection.SetActive(isSelected); |
| | 416 | |
|
| 3 | 417 | | if (isSelected) |
| 2 | 418 | | ResetPreviewPanel(); |
| 3 | 419 | | }); |
| | 420 | |
|
| 17 | 421 | | emotesCustomizationDataStore.isEmotesCustomizationSelected.OnChange += OnEmotesCustomizationSelected; |
| 17 | 422 | | } |
| | 423 | |
|
| | 424 | | private void OnEmotesCustomizationSelected(bool current, bool previous) |
| | 425 | | { |
| 2 | 426 | | if (current) |
| 1 | 427 | | sectionSelector.GetSection(EMOTES_SECTION_INDEX).SelectToggle(); |
| 2 | 428 | | } |
| | 429 | |
|
| | 430 | | public void ResetPreviewPanel() |
| | 431 | | { |
| 4 | 432 | | backpackPreviewPanel.ResetPreviewEmote(); |
| 4 | 433 | | backpackPreviewPanel.ResetPreviewRotation(); |
| 4 | 434 | | SetAvatarPreviewFocus(PreviewCameraFocus.DefaultEditing, false); |
| 4 | 435 | | } |
| | 436 | |
|
| | 437 | | private void UpdateAvatarModelWhenNeeded() |
| | 438 | | { |
| | 439 | | async UniTaskVoid UpdateAvatarAsync(CancellationToken ct) |
| | 440 | | { |
| | 441 | | try |
| | 442 | | { |
| 1 | 443 | | await backpackPreviewPanel.TryUpdatePreviewModelAsync(avatarModelToUpdate, ct); |
| 1 | 444 | | backpackPreviewPanel.SetLoadingActive(false); |
| 1 | 445 | | OnAvatarUpdated?.Invoke(); |
| 1 | 446 | | } |
| 0 | 447 | | catch (OperationCanceledException) { Debug.LogWarning("Update avatar preview cancelled"); } |
| 0 | 448 | | catch (Exception e) { Debug.LogException(e); } |
| 1 | 449 | | } |
| | 450 | |
|
| 3 | 451 | | if (!isAvatarDirty) |
| 2 | 452 | | return; |
| | 453 | |
|
| 1 | 454 | | updateAvatarCts = updateAvatarCts.SafeRestart(); |
| 1 | 455 | | UpdateAvatarAsync(updateAvatarCts.Token).Forget(); |
| 1 | 456 | | isAvatarDirty = false; |
| 1 | 457 | | } |
| | 458 | |
|
| | 459 | | private void OnColorPickerColorChanged(Color newColor) => |
| 0 | 460 | | OnColorChanged?.Invoke(newColor); |
| | 461 | |
|
| | 462 | | private void ColorPickerToggle() => |
| 0 | 463 | | OnColorPickerToggle?.Invoke(); |
| | 464 | |
|
| | 465 | | private void PlayTransitionAnimation(SignUpStage stage) |
| | 466 | | { |
| 0 | 467 | | Vector2 wearablesBackgroundForSignUpEndPosition = originalAnchorPositionOfWearablesBackgroundForSignUp; |
| 0 | 468 | | if (stage == SignUpStage.SetNameAndEmail) |
| 0 | 469 | | wearablesBackgroundForSignUpEndPosition.x += transitionDistance; |
| 0 | 470 | | wearablesBackgroundForSignUp.DOAnchorPos(wearablesBackgroundForSignUpEndPosition, transitionDuration).SetEas |
| 0 | 471 | | wearablesBackgroundForSignUpCanvasGroup.DOFade(stage == SignUpStage.CustomizeAvatar ? 1f : 0f, transitionDur |
| 0 | 472 | | wearablesBackgroundForSignUpCanvasGroup.blocksRaycasts = stage == SignUpStage.CustomizeAvatar; |
| | 473 | |
|
| 0 | 474 | | Vector2 wearablesSectionEndPosition = originalAnchorPositionOfWearablesSection; |
| 0 | 475 | | if (stage == SignUpStage.SetNameAndEmail) |
| 0 | 476 | | wearablesSectionEndPosition.x += transitionDistance; |
| 0 | 477 | | (wearablesSection.transform as RectTransform).DOAnchorPos(wearablesSectionEndPosition, transitionDuration).S |
| 0 | 478 | | wearablesSectionCanvasGroup.DOFade(stage == SignUpStage.CustomizeAvatar ? 1f : 0f, transitionDuration).SetEa |
| 0 | 479 | | wearablesSectionCanvasGroup.blocksRaycasts = stage == SignUpStage.CustomizeAvatar; |
| 0 | 480 | | } |
| | 481 | | } |
| | 482 | | } |