Пример #1
0
 public void UpdateExpressions(string id, long timestamp)
 {
     model.expressionTriggerId        = id;
     model.expressionTriggerTimestamp = timestamp;
     animator.SetExpressionValues(id, timestamp);
 }
Пример #2
0
        private IEnumerator LoadAvatar()
        {
            if (string.IsNullOrEmpty(model.bodyShape))
            {
                isLoading = false;
                this.OnSuccessEvent?.Invoke();
                yield break;
            }

            if (bodyShapeController != null && bodyShapeController.id != model?.bodyShape)
            {
                bodyShapeController?.CleanUp();
                bodyShapeController = null;
            }

            if (bodyShapeController == null)
            {
                HideAll();

                bodyShapeController = new BodyShapeController(ResolveWearable(model.bodyShape));
                SetupDefaultFacialFeatures(bodyShapeController.bodyShapeType);
                bodyShapeController.Load(transform, OnWearableLoadingSuccess, OnWearableLoadingFail);
            }
            else
            {
                //If bodyShape is downloading will call OnWearableLoadingSuccess (and therefore SetupDefaultMaterial) once ready
                if (bodyShapeController.isReady)
                {
                    bodyShapeController.SetupDefaultMaterial(defaultMaterial, model.skinColor, model.hairColor);
                }
            }

            int wearableCount = model.wearables.Count;

            for (int index = 0; index < wearableCount; index++)
            {
                var wearableId = this.model.wearables[index];

                if (!wearablesController.ContainsKey(wearableId))
                {
                    ProcessWearable(wearableId);
                }
                else
                {
                    UpdateWearable(wearableId);
                }
            }

            yield return(new WaitUntil(AreDownloadsReady));

            bodyShapeController.RemoveUnusedParts();

            bool eyesReady     = false;
            bool eyebrowsReady = false;
            bool mouthReady    = false;

            var eyeCoroutine = CoroutineStarter.Start(eyesController?.FetchTextures((mainTexture, maskTexture) =>
            {
                eyesReady = true;
                bodyShapeController.SetupEyes(eyeMaterial, mainTexture, maskTexture, model.eyeColor);
            }));

            var eyebrowCoroutine = CoroutineStarter.Start(eyebrowsController?.FetchTextures((mainTexture, maskTexture) =>
            {
                eyebrowsReady = true;
                bodyShapeController.SetupEyebrows(eyebrowMaterial, mainTexture, model.hairColor);
            }));

            var mouthCoroutine = CoroutineStarter.Start(mouthController?.FetchTextures((mainTexture, maskTexture) =>
            {
                mouthReady = true;
                bodyShapeController.SetupMouth(mouthMaterial, mainTexture, model.skinColor);
            }));

            faceCoroutines.Add(eyeCoroutine);
            faceCoroutines.Add(eyebrowCoroutine);
            faceCoroutines.Add(mouthCoroutine);

            yield return(new WaitUntil(() => eyesReady && eyebrowsReady && mouthReady));

            isLoading = false;

            SetWearableBones();
            animator.SetExpressionValues(model.expressionTriggerId, model.expressionTriggerTimestamp);

            yield return(null);

            CleanUpUnusedItems();

            yield return(null);

            ResolveVisibility();

            OnSuccessEvent?.Invoke();
        }